Changing grid's page happens only after return

2 posts, 0 answers
  1. Gregory
    Gregory avatar
    30 posts
    Member since:
    Feb 2014

    Posted 11 Apr 2018 Link to this post

    Anyone know why when I change my grid's page it only seems to really change the page after my function completes? e.g. 

    var g = $("#MyGrid").data("kendoGrid");;


    If I try to find a record on this new page by doing something like this: 

    var dataItem = g.dataSource.get(MyRecordID);

    DataItem is unknown

    But if I wait until the function finishes it does change the grid's page.

    If I set a breakpoint I can see the grid's datasource page is set to 2, but the data still has the old page one loaded...

  2. Preslav
    Preslav avatar
    579 posts

    Posted 13 Apr 2018 Link to this post

    Hello Gregory,

    Based on the provided information, I assume that you are using the Grid with server operations(the data for every page is requested on demand). Please correct me if I am wrong.

    If this is the case, when the page is changed, the new data for this page is not yet on the client(in the dataSource), and thus the get method returns undefined. What I could suggest is handling the dataBound event of the Grid and get the desired record there.
    Please, give the above a try, and let me know if it works for you.

    Progress Telerik
    Try our brand new, jQuery-free Angular 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