I have a virtual remote data enabled grid configured like this:
Basically, I would like to refresh the grid, scroll all the way up (usually, this is done by the refresh call) and finally, I would like to select the first row.
I created the following code:
However, the call to the refresh function is executed asynchronously. As the grid datasource is consuming an OData service to load only a subset of data when you scroll up or down, it does make sense.
So even if the call to the refresh function is made before the select call, the displayed row will be updated after the select call and will also remove any row selection in the grid.
I know it could possible to solve this problem by creating some kind of message system that could be handled by the grid's dataBound event, but I would like to know if anyone has a more simple solution for this.
Best regards,
Simon
var
myDataSource =
new
kendo.data.DataSource({
transport: {
read: {
url:
'http://localhost/MyODataService.asmx'
,
dataType:
'jsonp'
,
data: {
$select:
'RecordID, FirstName, LastName'
}
},
parameterMap:
function
(data, operation) {
if
(operation ==
'read'
) {
return
kendo.data.transports[
'odata'
].parameterMap(data, operation);
}
else
{
return
JSON.stringify(data.models);
}
}
},
type:
'odata'
,
pageSize: 200,
serverPaging:
true
,
serverSorting:
true
,
batch:
true
});
jQueryGrid.kendoGrid({
dataSource: myDataSource
height: 530,
scrollable: {
virtual:
true
},
reorderable:
true
,
resizable:
true
,
sortable:
true
,
columns: [
'RecordID'
,
'FirstName'
,
'LastName'
],
selectable:
'row'
});
I created the following code:
myGrid.data(
'kendoGrid'
).dataSource.read();
myGrid.data(
'kendoGrid'
).refresh();
myGrid.data(
'kendoGrid'
).select(
'tr:eq(0)'
);
So even if the call to the refresh function is made before the select call, the displayed row will be updated after the select call and will also remove any row selection in the grid.
I know it could possible to solve this problem by creating some kind of message system that could be handled by the grid's dataBound event, but I would like to know if anyone has a more simple solution for this.
Best regards,
Simon