Hello, how are you?
I'm having trouble with the Lazy Loading function in the SfGrid. It should make a request limited by the "PageSize" number, but it returns all the data, making it slow.
This is the Grid with the AllowPaging and PageSize properties enabled
This is the Controller, returning the object with Items and Count as recommended by the Documentation. This query returns all the data, but it should be limited by the PageSize and the Lazy Loading (and if I'm wrong, please correct me on this)
When the code is executed, this is the request executed. But it takes too much time, and all the results are loaded
If I limit the query in the Controller using Take(10), it works, but only with the 10 first results.
Am I doing something wrong?
How can I make the Lazy Loading work properly?
I'm sending the code for further details.
Best Regards,
Eduardo
[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 (filter != null) // to handle filter opertaion
{
. . . .
}
if (sort != null) //Sorting
{
. . . . .. ..
}
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;
}
}
|