0

I want to custom pagination using datatable with angularjs mvc c#. i know inbuilt feature is avilable for pagination but don't used it.want to create custom so how can do that i don't know.

here this code for list my user list:

 $scope.dtColumns = [ DTColumnBuilder.newColumn("fullName", "Full Name"), DTColumnBuilder.newColumn("email", "Email"), ] $scope.dtOptions = DTOptionsBuilder.newOptions().withOption('ajax', { url: "/api/User/UserList", type: "GET", contentType: "application/json; charset=utf-8", }) .withPaginationType('full_numbers') .withDisplayLength(50) .withOption('paging', false) 

here my html code :

<table id="userList" datatable="" dt-options="dtOptions" dt-columns="dtColumns"> </table> 

this my api method:

[HttpGet] [Route("UserList")] public IHttpActionResult UserList() { Users = db.Users.ToList(); return Json(Users); } 

any one know how can do that then please let me know.

2 Answers 2

0

You can use the OData convention to do what you want.

You can use $top and $skip URL parameters to achieve what you want

Edit: With this method, your URL will be /api/User/UserList?$top=[your_top]&$skip=[your_skip] where [your_top] will be the number of items you want, and [your_skip] will be the number of items you want to pass.

Eg: $top=10&$skip=0 will be the 10 first items

$top=10&$skip=10 will be from the 10th to 20th items ... etc

You can see how to deal with query string with aspnet web api here

At this time, you can use thoses parameters to filter your items.

Sign up to request clarification or add additional context in comments.

1 Comment

hi but in this code how can used $top and $skip and what you want to say i m not understand propare can you please explain this topic other wise give me any hint.
0

i am refer this blog and able to server side pagination.here this link for blog.

http://www.dotnetawesome.com/2016/01/datatables-server-side-paging-sorting-filtering-angularjs.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.