Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Client side sorting in datatable with serverside = true

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.

like image 833
user3871494 Avatar asked Jul 24 '14 05:07

user3871494


People also ask

What is Serverside in DataTables?

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.

How do I sort a specific column in a DataTable?

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 });

How does DataTable sorting work?

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.


1 Answers

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.

like image 190
Hank Lapidez Avatar answered Nov 15 '22 02:11

Hank Lapidez