Hi
How to do Paging in Jquery DataTable. In the below Method it will display all records from the Database.
Suppose there are 14 records & 5 records per page setting. I want that is should bring 1-5 records . If user clicks on 3 them 11-14 records should be displayed.
- public ActionResult Index()
- {
- return View();
- }
- @model IEnumerable
- "viewport" content="width=device-width" />
Index class="table" id="tblLocation">
- @Html.DisplayNameFor(model => model.Description)
- @foreach (var item in Model)
- {
- @Html.DisplayFor(modelItem => item.Description)
- }
- ********************************************
- $(document).ready(function () {
- //$('#dataTable').DataTable();
- $("#tblLocation").dataTable({
- ajax: {
- type: "get",
- url: "/Location/List",
- dataType: "json",
- dataSrc: ""
- },
- columns: [
- {
- data: "Id",
- visible: false
- },
- {
- data: "Description"
- },
- {
- data: "LocationId",
- render: function (data) {
- return "";
- }
- },
- {
- data: "PostId",
- render: function (data) {
- return "";
- }
- }
- ]
- });
- });
Thanks
Sachin SinghPosted May 28, 2021, 10:14 AM
Ramco RamcoPosted May 28, 2021, 9:53 AM
Sachin SinghPosted May 28, 2021, 8:22 AM
Jay Krishna ReddyPosted May 28, 2021, 4:50 AM