I would like to make some changes to the Kendo grid after it has been rendered (show/hide columns etc.). However the Kendo grid does not provide any onRendered
event. So how can I do this?
Earlier, I have used the dataBound
event to do this. It used to work aparently becuase the grid was already rendered by the time the data arrived from the AJAX request. However, my use case has changed - the data is now already available when the grid is declared. So the code inside the dataBound
event is not finding the grid. In the code below if (grid)
always returns false:
$('#mygrid').kendoGrid({
dataSource: {
data: myGridData
},
dataBound: function() {
// Check if the grid has been rendered
var grid = $('#mygrid').data('kendoGrid');
if (grid) {
// Show/hide columns
...
}
},
...
});
I also tried to move the check after the kendoGrid() call, but that still does not work. The grid has not yet been rendered right after the call.
$('#mygrid').kendoGrid({
dataSource: {
data: myGridData
},
...
});
// Check if the grid has been rendered
var grid = $('#mygrid').data('kendoGrid');
if (grid) {
// Show/hide columns
...
}
I could use a setTimeout() before doing the check, but that feels like a hack! Is there any other way? Can Kendo Grid introduce an event such as onRendered
? I feel that that would be the right way to solve this issue.
Thanks in advance for your time.