问题
I am using jQuery DataTables.
searchResultsTable = $("#searchResultsTable").dataTable({
"bServerSide": true,
"sAjaxSource": "searchResults.form",
"bProcessing": false,
"sPaginationType": "full_numbers",
"oLanguage": {"sEmptyTable": "No data available", "sLengthMenu" :" _MENU_ items per page",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ records",
"sInfoEmpty": "No entries to show"},
"sDom": 'tlip',
"aaSorting": [],
"aoColumns": [null,null,null,null,{ "bVisible": false }]
});
I have provided the aaSorting
, so that the data gets sorted when user clicks on the header. But it's not working. Am I missing something?
回答1:
CAUSE
You have server-side processing mode enabled with "bServerSide": true
. In this mode, data processing including sorting, filtering and ordering should be performed on the server and the returned data need to have certain structure. See Processing modes for more information.
SOLUTION
If you are not performing data processing on the server, simply remove "bServerSide": true
and DataTables will perform sorting, filtering and ordering on the client-side.
来源:https://stackoverflow.com/questions/32201482/unbable-to-sort-the-columns