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

Accumulate paged data in datasource

3 Answers 115 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 2
Dave asked on 30 Apr 2013, 02:58 AM
I have a remote data service that is set at the server side to pagesize 100.

I need to get 10000+  records back using a single query.

How do I do that?

I have tried using the add and splice methods on an observableArray object but nothing has worked. I have looked all over the place for an example or something close and have not seen anything.

example attempt from inside DataSource Object:

  schema: {
                data: function (response) {
                    //apply response to field that was in activeQuery
                    totalCount = response.totalCount;
// .set overwrites the returned set every time with the next page of data
                    assetViewModel.set("assets", response.assets);
// length is forever 0 with this
                    assetViewModel.assets_ds = response.assets.splice(assetViewModel.assets_ds.length,0,response.assets);
// tried using .add but this only works iterating through each of the 100 returned items in a loop - not performant
                    // we only have the first page of results from assetDataSource at this point
                  // we can process what we have so far and come back for next page 
                    locationsDataSource.read();
                    return response;
                },

if you need to see more we have to share files off forum thank you!

<update>
found allAssets = allAssets.concat(assetViewModel.assets.slice(0)); is slightly faster than a for loop through response to add items to allAssets

<update #2>
if you have a server that pages out data in small chunks the service calls will be the main slowdown - set expecations appropriately : )

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 01 May 2013, 04:25 PM
Hello David,

I am afraid I do not understand what exactly is your goal. Could you please describe it in more details and if possible give example scenarios describing the whole work flow?

Basically the dataSource supports the client operations mode and the server operations mode.

http://docs.kendoui.com/api/framework/datasource#configuration-serverPaging

If the serverPaging is set to false all the records will be fetched from the server and paging will be applied on the client each time the user clicks the pager.

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dave
Top achievements
Rank 2
answered on 02 May 2013, 03:08 AM
The server I am connected to does not let me change the paging scheme - so if I want more than one page of data on the client side I have to request each page and build a proxy.

I have since worked the problem by chunking through the data pages one at a time but would prefer to build a proxy cache of results. That is my question: What is the best way to build a proxy data cache on the client, built up form pages of data?

Thanks!

Dave
0
Petur Subev
Telerik team
answered on 03 May 2013, 11:18 AM
Hello David,

Please notice the question how to get and batch all the pages for the server is not directly related to Kendo. Once you manage to put all the records in a single array you can simply add and display that array in the Grid through the data function of the dataSource.

Another approach would be to specify the transport.read as a function and once you fetch all the pages and combine them in a single array pass it to the success callback like shown in the docs.

http://docs.kendoui.com/api/framework/datasource#configuration-transport.read


Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Dave
Top achievements
Rank 2
Answers by
Petur Subev
Telerik team
Dave
Top achievements
Rank 2
Share this question
or