I want to create a grid where the data for the grid comes from a remote datasource but then is re-packaged by a javascript function after the data arrives but before it is displayed (repackaged means some rows are dropped and only some fields are displayed). The grid needs to show a loading gif (as per usual) while waiting for the remote datasource and javascript function to complete processing. What is the right way to set this up?
This sort of thing (below) for example doesn’t work, because the processData() function completes without waiting for the remote datasource to return its data, plus the grid isn’t aware it needs to invoke its loading.gif.
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "REMOTE URL
}
}
}
});
function processData() {
dataSource.read();
var dataTobeProcessed = dataSource.data();
...
return processedData;
}
$("#grid").kendoGrid({
dataSource: {
data: processData()
},
columns: [ { …} ]
})