Is there a way to not have this return the data in the grid?
When I execute grid.getOptions() it returns the data along with the configurations of the grid.
In the demo I did not see the grid data returned.
3 Answers, 1 is accepted
0
Dimo
Telerik team
answered on 19 Dec 2014, 04:25 PM
Hi Shawn,
If the Grid is bound to local data, which is provided in the widget dataSource configuration, then the getOptions() method will return it and this is expected. In such cases you can remove the data manually from the returned object.
The demo that you are referring to, uses remote data, so naturally, the configuration options contain the web service settings, but not the data itself.
Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
When the options are reapplied back to the grid then that specific data is restored along with it, not just the column width, order, sorting, groupings, filters and etc.
Is there a way to just apply the grid setup and not the data OR will that happen when I removed the data from the getOptions, apply that via set options and then reload local data?
We did this brute force before where we looped through picking out each area, saving it and reapply and whatever data was in the grid it was applied.
0
Dimo
Telerik team
answered on 22 Dec 2014, 11:33 AM
Hi Shawn,
setOPtions() destroys the Grid and recreates it by merging its old configuration with the new settings. That's why there are two possible scenarios when using local data:
1. Delete the data field from the dataSource settings after using getOptions(). When the Grid is recreated afterwards with setOptions(), its data will remain the same as before.
var gridOptions = grid.getOptions();
delete gridOptions.dataSource.data;
or
2. Assign an empty array to the data field of the dataSource settings after using getOptions(). Then the Grid data (and table) will be cleared, when executing setOptions().
var gridOptions = grid.getOptions();
gridOptions.dataSource.data = [];
On a side note, you can change the Grid data at any time via the API: