I have the following datatable created with server-side processing enabled:
$(document).ready(function() {
oTable = $('#example').dataTable( {
"bServerSide": True,
"sAjaxSource": "source.php",
"aaSorting": [[0,"asc"]],
"aoColumns": [
{ "mDataProp" : "Name",
"sType": "string-case" },
{ "mDataProp" : "Priority",
"sType": "string-case" },
{ "mDataProp" : "Action",
"sType": "string-case" }
]
} );
} );
Name, Priority, and Action are all strings I would like to sort on. Whenever I click on the column header it does nothing but reload the table. Probably a stupid question, but do I need to do all my sorting serverside (using the iSortCol_0 and sSortDir_0 as my identifiers)? Is it possible to sort clientside without refreshing the table like this and actually have it sort based on the names?
When using
bServerSide: trueDataTables will only ask for the data which will fit on the current page. When you proceed to the next page, it will ask for the next 10 records, for example. It is not possible for DataTables to sort on the client as it doesn’t know the whole data set.If you simply want to pull the entire data set from an ajax source you can use the
sAjaxSourceoption.Example: http://datatables.net/release-datatables/examples/data_sources/ajax.html