Clear sorting instead of fnSort([]);
Clear sorting instead of fnSort([]);
Hi.
I lost one day trying to find other solution for clear all sorting.
At first I used
[code]
oTable.fnSort([]);
[/code]
But i have to find other solution for clearing
I found solution for search reset with this function
[code]
$.fn.dataTableExt.oApi.fnResetAllFilters = function (oSettings) {
for(iCol = 0; iCol < oSettings.aoPreSearchCols.length; iCol++) {
oSettings.aoPreSearchCols[ iCol ].sSearch = '';
}
oSettings.oPreviousSearch.sSearch = '';
}
[/code]
I also tried with this
[code]
$.fn.dataTableExt.oApi.fnResetAllSorting = function (oSettings) {
oSettings.aaSorting = [];
}
[/code]
but it doesn't work.
I lost one day trying to find other solution for clear all sorting.
At first I used
[code]
oTable.fnSort([]);
[/code]
But i have to find other solution for clearing
I found solution for search reset with this function
[code]
$.fn.dataTableExt.oApi.fnResetAllFilters = function (oSettings) {
for(iCol = 0; iCol < oSettings.aoPreSearchCols.length; iCol++) {
oSettings.aoPreSearchCols[ iCol ].sSearch = '';
}
oSettings.oPreviousSearch.sSearch = '';
}
[/code]
I also tried with this
[code]
$.fn.dataTableExt.oApi.fnResetAllSorting = function (oSettings) {
oSettings.aaSorting = [];
}
[/code]
but it doesn't work.
This discussion has been closed.
Replies
Allan
Allan
I'd like to give my user the ability to sort selected rows to the top of the table. To do so I set a value in a hidden column on the tr click event then attempt to call fnSort on that column. The fnDraw blows away the hidden values that I set and thus I lose the ability to sort on the selected items.
Is there another way to do this without relying on a hidden column?
Having said that, I don't understand why fnDraw would blow away values you set in a column, unless you are using server-side processing. Please link to an example :-)
Allan
Here's a use case I've been dealing with that would benefit from not redrawing when sorting (I'm using 1.9.3 btw:
When initializing the datatable I need to give a value to a column based on the "order number" that is stored. I would get something like this:
[{"id": "92, "order": "3"}, {"id": "94", "order": "", {"id": 95, "order": "1"} ... ]
By default the table is ordered by "id" and there's a checkbox that displays the order column and some controls in case the user wants to set her own order (and change the "order" value).
The thing here is that there are some rows that do not have an "order" and I would like to set it to the row they are displayed when sorted using "numWithNull" sorting (http://datatables.net/forums/discussion/9784/sort-columns-with-numbers-and-empty-cells/p1)
What I would like to do is to sort it as numWith-null on the initCallback so I can set the correct row and then sort it back again by the default sort. The problem is that this makes the table "move" for the user when loading.
Pretty sure there's a better way that I'm unaware of, though :P
p.s. As always, great job you've done Allan! Thank you so much!