server-side processing function
server-side processing function
After getting data from the server, for example :
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "xhr.php"})}
I want to sort the data by the specified column on the client side using js language, what should I do ? How to sort the data I get from the server using the functions datatable provide?
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "xhr.php"})}
I want to sort the data by the specified column on the client side using js language, what should I do ? How to sort the data I get from the server using the functions datatable provide?
This discussion has been closed.
Replies
If you do want to do that however, you could use fnServerData to intercept the JSON return from the server and just use standard Javascript sorting techniques before passing it on to DataTables for display.
Allan
You can also provide an intialization variable to declare the default sorting you want:
[code]
/* Sort by 3rd column first, and then 4th column */
$(document).ready( function() {
$('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "xhr.php",
"aaSorting": [[2,'asc'], [3,'desc']] /// specify default sort state
} );
} );
[/code]