AngularJs Grid - need to update page number without causing request to server

7 posts, 0 answers
  1. Itay
    Itay avatar
    16 posts
    Member since:
    Nov 2015

    Posted 13 Jan 2016 Link to this post

    Sometimes my grid raises a request to server with page=1 but the server returns as a result page number 3.
    I need to change the page number in the grid to 3 but without causing a new ajax request like happens with:

    grid.data("kendoGrid").dataSource.page(pageNumber);

     Thanks

     

  2. Dimo
    Admin
    Dimo avatar
    8485 posts

    Posted 15 Jan 2016 Link to this post

    Hello Itay,

    Let me confirm that I understand you correctly - the Grid requests the items for page 1, but the server incorrectly returns the items for page 3 and this behavior is not caused by Kendo UI, right?

    Changing the page number always triggers a request, because the Grid doesn't know that it has already received the data for the desired page by mistake. I am afraid I cannot suggest any workarounds in this case.

    Regards,
    Dimo
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Itay
    Itay avatar
    16 posts
    Member since:
    Nov 2015

    Posted 15 Jan 2016 Link to this post

    Hello Dimo,

    We would like to set the grid to an initial position based on an item id without knowing the page number. Once the response page is displayed we’d like to user to continue paging as usual.

    Here is the desired use-case in details. The initial request contains a filtered request where the actual page number is unknown. The desire is to get to a known item whose position is unknown and then let the user continue the paging process as she pleases. The server puts the page number in the response and we’d like to set this page to the grid, including the paging buttons value. We then would like to grid to act as usual. We manage to add the custom filtering parameter using transport/data function. What we fail to do is to set the page number to the grid, without causing the grid to trigger another request.

    Is there a way to properly turn off auto-bind, setting the page and then turn auto-bind on again?
    We hope there is an elegant way to get this use case work with a single server request.

    Thanks
  4. Benjamin
    Benjamin avatar
    21 posts
    Member since:
    Apr 2015

    Posted 18 Jan 2016 Link to this post

    Hi,

     in Combobox this behaviour could be achieved by using the value mapper function. I'm not sure if its possible in grid too.

  5. Dimo
    Admin
    Dimo avatar
    8485 posts

    Posted 19 Jan 2016 Link to this post

    Hello,

    The described Grid scenario requires the correct page number to be known in advance and the Grid DataSource to be paged to that particular page. In other words, use one custom Ajax request for the page number and then the Grid will use a standard read request for the data from that page.

    Regards,
    Dimo
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Syleps
    Syleps avatar
    35 posts
    Member since:
    Nov 2013

    Posted 27 Aug 2017 in reply to Dimo Link to this post

    Hi,

    I have a similar problem.

    In my case I don't know at the start of my grid the number of records; either because this one is very fluctuating, or because the calculation of the count is too expensive in execution time (more than fetch n records)

    So to have the pager, I return a count to maxint

    But when user go to the end of data, we can detect that and know the real number of rows, that the server returns in the DataSourceResult (in ASP.Net)

    The pager is then in an inconsistent situation where the currentPage > totalPages

    To correct this, the current page number is specified via the pager.page (n) method, but this automatically restarts a databound that is not necessary.

     

    Any solution ?

     

    Regards.

  7. Dimo
    Admin
    Dimo avatar
    8485 posts

    Posted 29 Aug 2017 Link to this post

    Hello Syleps,

    The Kendo UI DataSource is designed to perform a request when the page is changed, and this cannot be prevented. You actually can prevent the request, but this will also cancel the page change in the pager's UI.

    The only way to achieve the desired behavior is to use a custom DataSource transport:

    http://docs.telerik.com/kendo-ui/framework/datasource/crud#local-or-custom-transport-crud-operations

    In this case you will need to cache all received data on the client and when a "fake" request should be made, you will return the already available data from the desired page in the e.success() callback without an actual request.

    Regards,
    Dimo
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top