Hi
I am trying Grid paging feature with WebAPI and Below is my code sample-
HTML page-
<div id="example">
<div id="grid"></div>
<script>
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
//type: "odata",
serverPaging: true,
serverSorting: true,
pageSize: 5,
transport: {
read: "api/Audit"
}
},
height: 643,
pageable: true,
scrollable: {
virtual: false
},
sortable: true,
dataBound: function(e) {
console.log("dataBound");
},
columns: [
{ field: "AUDIT_ID", title: "AUDIT_ID" },
{ field: "AUDIT_TYPE", title: "AUDIT_TYPE" },
]
});
});
</script>
<style>
/*horizontal Grid scrollbar should appear if the browser window is shrinked too much*/
#grid table {
min-width: 1190px;
}
</style>
</div>
WebAPI Get method – Case 1
public IQueryable<AUDIT> GetAUDIT()
{
return db.AUDIT;
}
WebAPI Get method – Case 2
public IQueryable<AUDIT> GetAUDIT(int take, int skip, int page, int pageSize)
{
return db.AUDIT.Take(take * page).OrderBy(x => x.AUDIT_ID).Skip(skip);
}
In Case 1,
I am receiving all the records irrespective of page size.
Every time, I click on next page, it fetches all records again and shows records from row number 1.
In Case 2,
I am able to show only one page size records and it always remains as Page1. I couldn't see multiple pages
These are my requests
http://localhost:49736/api/Audit?take=5&skip=0&page=1&pageSize=5
http://localhost:49736/api/Audit?take=5&skip=5&page=2&pageSize=5
Could you please help me on this?
Cheers
Sanket