Filter breaks sorting
Filter breaks sorting
koosvdkolk
Posts: 169Questions: 0Answers: 0
I have a 1.9.4 datatable (which is encapsulated in a object, making it difficult to post a test case) in which the column sorting breaks when the user uses the 'global' search. The columns are being filtered, but become unresponsive to sorting. Removing the global search filter restores the ordering functionality.
After digging in the code I found out that _fnDraw is being called, but it just does not create the sorted table.
Furthermore, when an individual column is being filtered, sorting keeps on working.
Any clue what could be causing this?
After digging in the code I found out that _fnDraw is being called, but it just does not create the sorted table.
Furthermore, when an individual column is being filtered, sorting keeps on working.
Any clue what could be causing this?
This discussion has been closed.
Replies
[code]
if (filter) {
_fnFilterComplete(settings, settings.oPreviousSearch);
}
else {
// No filtering, so we want to just use the display master
settings.aiDisplay = settings.aiDisplayMaster.slice();
}
console.log(settings.aiDisplay, settings.aiDisplayMaster);
[/code]
If I use the 'global search', the order in settings.aiDisplay != the order in settings.aiDisplayMaster after sorting.
If I use 'one column search', the order in settings.aiDisplay == the order in settings.aiDisplayMaster after sorting.
When sorting, _fnFilterComplete calls _fnFilter when there is text in the global search input.
In the _fnFilter code, it says somewhere:
[code]
/* Using old search array - refine it - do it this way for speed
* Don't have to search the whole master array again
*/
[/code]
it seems to be some kind of 'caching' mode. In my case, this caching breaks the sorting, as _fnFilter does not consider the (sorted) aiDisplayMaster but the table as is.
So if I force fnFilter to not use this caching (iForce = true), my problem is solved.
Now the $1.000.000 question is: how come that I am the only one having this problem?
Allan