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

How to set page without triggering data sync

1 Answer 331 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 05 Nov 2012, 09:08 PM
I am using the Kendo Grid with a custom sort criteria component, and also storing the grid state so as to return the grid to the state it was in when the page is reloaded at a later stage. In so doing, I need to set the grid to a specific page, and pass additional values to the read action.

 I do not know how to set the page number along with the additional data in one call, so I am setting the grid page and calling read on the dataSource to achieve what I want. Naturally, I would prefer to do this in one call. So, what I want to know is: Can you set the page on the grid without triggering a dataSource read?

I read about the autoSync property, and thought I could temporarily set it to false (while setting the page number), but the property does not seem to be there. Was it deprecated?

 And:
Can I set the read to be a JavaScript function, so as to pass additional values that way? I know I can call the read method from script, and I am, but I want to make the "default" read (the one triggered when paging) to be a javaScript function.

Edit:
I just found the example that illustrates passing additional data to the read action by calling a javaScript function. Nice! So please ignore the second question. So, the only issue I have left is how to get back data and jump to a specific page in one step (without resulting in two calls to the read action).

2nd edit: 
Sorry, I typed this in the early hours of the morning and was not very coherent. What I am looking to do can be distilled to the following: 

Is it possible to, on the initial load (page loading for the first time with a Kendo Grid), set the grid to start on a specific page (other than page 1)? 
What I have done is to add  a hidden element to the page with the page number I want to set the grid to as the value. Then, by binding to the databound event, I can check this value and, if it is required (if it is greater than 1), set the grid's page number to this value, which then triggers the read. This works, but it means two calls to the read action (the initial one, and the one for the page jump). I tried switching off the autoBind, but it still requires two calls to get the grid set. It seems that calling the read action with a page number greater than the current page set causes it to be ignored and revert to page 1. So, one has to load page 1, then jump to the page you want.

Is there any way to set the grid's initial page number, so as to avoid the double data read?

  

1 Answer, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 2
answered on 15 Nov 2013, 01:47 PM
For anyone else looking how to do this as I was.

If you use the grid's dataSource.query({page:1, pageSize: 10, etc...}) method you can set these options with just one call to the server. Hope this helps anyone else looking how to do this.

Patrick
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 2
Share this question
or