How to set page without triggering data sync

2 posts, 0 answers
  1. Mark
    Mark avatar
    2 posts
    Member since:
    Nov 2012

    Posted 05 Nov 2012 Link to this post

    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?

    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.

    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?


  2. Patrick
    Patrick avatar
    19 posts
    Member since:
    Jul 2010

    Posted 15 Nov 2013 Link to this post

    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.

Back to Top