I am working with a Kendo grid that has several columns. I want to be able to update the visibility of some columns, add new ones, and then display the updated data after a button click.
Here is my attempt at achieving this:
// GET THE EXISTING COLUMNS FROM THE GRID
var existingColumns = grid.columns;
// MAKE CHANGES TO COLUMN VISIBILITY IN A LOOP
for loop
// SET THE UPDATED COLUMNS BACK TO THE GRID
$("#orders_grid").data('kendoGrid').fields(existingColumns);
// POPULATE THE GRID WITH FRESH DATA FROM THE SERVER
$("#orders_grid").data('kendoGrid').dataSource.read();
// REFRESH THE GRID
$("#orders_grid").data('kendoGrid').refresh();
However, the code crashes on this line:
$("#orders_grid").data('kendoGrid').fields(existingColumns);
Can someone please advise me on how to do this correctly?