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!
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!
4 comments on "Server side paging, filtering and sorting using datatables"
Subscribe in a Reader
Good article ! thanks !
http://www.dotnetawesome.com/2015/11/implement-jquery-datatable-in-aspnet-mvc.html
Here we will see followings with ASP.NET MVC as server side...
Part 1: Implement jQuery Datatable (Basic initialization) in ASP.NET MVC application.
Part 2: jQuery Datatable server side pagination and sorting in ASP.NET MVC
Part 3: Implement custom multicolumn server-side filtering in jQuery dataTables
I was trying to find the way to do server-side pagination. The example in datatable.net did not work for me . Your solution is perfectly working . Thank you very much. If you would be in Istanbul , I could buy you a drink :) Thanks a lot !
I was trying to find the way to do server-side pagination. The example in datatable.net did not work for me . Your solution is perfectly working . Thank you very much. If you would be in Istanbul , I could buy you a drink :) Thanks a lot !
Post a Comment