This is a migrated thread and some comments may be shown as answers.

Custom paging when using Remote Virtualization

1 Answer 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tor
Top achievements
Rank 1
Tor asked on 14 Feb 2013, 11:28 PM
I am using the Kendo grid in remote virtualization mode for a very large data set. My stored procedures are aware of paging and capable of returning partial data fetches, instead of returning all rows for every request. Each service call will return exactly one page worth of data (100 records) based on my start/end markers. I use the request object to calculate the appropriate offsets for the next pull.

There are several 1000 records in my total record set, so I would like to avoid pulling all the data for every request.

However, for some reason I am not able to use ToDataSourceResult to build the JSON object that the grid expects to be passed back from my virtualization action:

EX:
public ActionResult Virtualization_GetProducts([DataSourceRequest] DataSourceRequest request, int productId)
        {
   int startIndex = (request.Page - 1) * request.PageSize + 1;
            int endIndex = startIndex + request.PageSize - 1;
            var result = service.GetProducts(productId,startIndex,endIndex);

            return Json(result.ToDataSourceResult(request));
        }

The result that I get is {"Data":[],"Total":100,"AggregateResults":null,"Errors":null} -- even though I get back the expected result from the service.

If I instead return all the data without using startIndex/endIndex the grid is able generate the correct JSON.

All the examples I've found (including your demo) involve pulling all the data in your data source every time. Is there a way to make this work with a data source that supports its own paging like above?

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 15 Feb 2013, 09:04 AM
Hello Tor,

In order to handle the data processing yourself you should not relay on ToDataSourceResult extension but create and populate the DataSourceResult instance manually. As you know the ToDataSourceResult extension method will process the data based on the request object. Thus, in your case it will try to page already paged data and will return nothing.

Please refer to this help article for more information on setting custom binding.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Tor
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or