My question is, I have a web api that returns like 20k records, instead of calling all these records at once and populate into grid, what I want the grid to behave is to create pages (and make pagination) by dividing total number of records (20k) with my grid per page size (10), and the grid to be populated when I selected any page from pagination, if page is selected, the web api will take two parameters (from grid) pageNumber(1) and pageSize(10), the api will be called and return 10 records (from the selected pageNumber, pageSize criteria) and will be populated into grid, this way I don't have to get all records from database, and wait for application for be loaded, as there may be 100k records.
|
[HttpGet]
public async Task<object> Get(int? code)
{
if (order.Count == 0)
{
BindDataSource();
}
var data = order.AsQueryable();
var queryString = Request.Query;
string grid = queryString["ej2grid"];
string sort = queryString["$orderby"]; //sorting
string filter = queryString["$filter"];
string auto = queryString["$inlineCount"];
. . .
if (queryString.Keys.Contains("$inlinecount"))
{
StringValues Skip;
StringValues Take;
int skip = (queryString.TryGetValue("$skip", out Skip)) ? Convert.ToInt32(Skip[0]) : 0;
int top = (queryString.TryGetValue("$top", out Take)) ? Convert.ToInt32(Take[0]) : data.Count();
var count = data.Count();
return new { Items = data.Skip(skip).Take(top), Count = count };
}
else
{
return data;
}
}
. . .
} |
Also have a look at this link :
It may help you.