fnSortNeutral not working as expected
fnSortNeutral not working as expected
neuDev33
Posts: 11Questions: 0Answers: 0
I'm trying to implement the fnSortNeutral functionality by using it as follows -
$(document).ready(function () {
$.fn.dataTableExt.oApi.fnSortNeutral = function (oSettings) {
/* Remove any current sorting */
oSettings.aaSorting = [];
/* Sort display arrays so we get them in numerical order */
oSettings.aiDisplay.sort(function (x, y) {
return x - y;
});
oSettings.aiDisplayMaster.sort(function (x, y) {
return x - y;
});
/* Redraw */
oSettings.oApi._fnReDraw(oSettings);
};
/* Init the table */
oTable = $('#headTable').dataTable({
"bPaginate": false,
bJQueryUI: true,
"bSortClasses": false,
"sDom": 'T<"clear">lfrtip',
........
..........
});
});
function clearSort()
{
oTable.fnSortNeutral();
}
However, when the clearSort functon is called, the table is sorted by the first column instead of clearing the sort and getting the table to display as it did when it loaded for the 1st time. Is this expected behavior? Or am i not using this correctly?
$(document).ready(function () {
$.fn.dataTableExt.oApi.fnSortNeutral = function (oSettings) {
/* Remove any current sorting */
oSettings.aaSorting = [];
/* Sort display arrays so we get them in numerical order */
oSettings.aiDisplay.sort(function (x, y) {
return x - y;
});
oSettings.aiDisplayMaster.sort(function (x, y) {
return x - y;
});
/* Redraw */
oSettings.oApi._fnReDraw(oSettings);
};
/* Init the table */
oTable = $('#headTable').dataTable({
"bPaginate": false,
bJQueryUI: true,
"bSortClasses": false,
"sDom": 'T<"clear">lfrtip',
........
..........
});
});
function clearSort()
{
oTable.fnSortNeutral();
}
However, when the clearSort functon is called, the table is sorted by the first column instead of clearing the sort and getting the table to display as it did when it loaded for the 1st time. Is this expected behavior? Or am i not using this correctly?
This discussion has been closed.
Replies
Allan