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 SinghRank #66 · 26.2K reputationPosted May 28, 2021, 4:22 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted May 28, 2021, 6:14 AM EDT
Jay Krishna ReddyRank #152 · 15.2K reputationPosted May 28, 2021, 12:50 AM EDT
Ramco RamcoRank #462 · 5.4K reputationPosted May 28, 2021, 5:53 AM EDT