I am using bServerside = true in the datatable to get data from the server, but I would like to do client side sorting on the data that I have got initially. My client side sorting is not working. If I use bServerside = false, it won't load data from the server.
DataTables' server-side processing mode is a feature that naturally fits with Scroller. Server-side processing can be used to show large data sets, with the server being used to do the data processing, and Scroller optimising the display of the data in a scrolling viewport.
The existing answers are using legacy DataTables syntax. Versions 1.10+ should use the following syntax: $('table'). dataTable({ "pageLength": -1, //display all records "order": [[ 0, "desc" ]] // Sort by first column descending });
Sorting by a click on the header. When you click on the header, DataTable starts to display a special control indicating which column the table is currently sorted by and the direction of this sorting (ascending or descending). Each new click on the same header will reverse the sorting direction.
As the datable documentation points out:
DataTables has two fundamental modes of operation:
Client-side processing - where filtering, paging and sorting calculations are all performed in the web-browser. Server-side processing - where filtering, paging and sorting calculations are all performed by a server.
http://datatables.net/reference/option/serverSide
When you get the data from the server normally you only get the portion of data that is currently displayed. When you sort, you must sort the over the complete data and therefore new data from the server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With