This is a migrated thread and some comments may be shown as answers.

Grid getOptions

3 Answers 851 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 2
Shawn asked on 18 Dec 2014, 08:41 AM
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

Sort by
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!
 
0
Shawn
Top achievements
Rank 2
answered on 19 Dec 2014, 11:22 PM
OK that makes sense.

One last question.

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:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#fields-dataSource
 
http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-data

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Shawn
Top achievements
Rank 2
Answers by
Dimo
Telerik team
Shawn
Top achievements
Rank 2
Share this question
or