Showing posts with label datatables. Show all posts
Showing posts with label datatables. Show all posts

Tuesday, November 5, 2013

Server side paging, filtering and sorting using datatables

4 comments
Nothing better than writing some code to explain a feature. This post shows how to do server-side paging in a table using datatables.net
The idea is to display a table with a large amount of data (68k rows). As it's not a good practice to load all at once, it' better to implement server-side paging.

First download datatables.net from here and reference them in your html file.

In our sample we are using a table Tasks with 3 fields, ie, TaskID, TaskName, Complete

Lets create the HTML markup first



Now lets wire up datatable to the table



Here as you can see TaskID and TaskName are sortable and searchable.
Now, the model that is passed from datatables to server-side



Finally, the controller method


That's all to it. Happy coding!

Read more...