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

Changing grid's page happens only after return

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gregory
Top achievements
Rank 1
Gregory asked on 11 Apr 2018, 07:35 PM

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");
g.dataSource.page(2);

 

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...

1 Answer, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 13 Apr 2018, 11:09 AM
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.


Regards,
Preslav
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.
Tags
Grid
Asked by
Gregory
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Share this question
or