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

Reset/Reload grid after it has initialized

1 Answer 1806 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 13 Aug 2014, 04:05 PM
I am using the Angular extensions with the grid.

I have a grid that looks like this:

<div kendo-grid k-options="testGridOptions" k-ng-delay="testGridOptions"></div>

In another directive I created (not shown in my sample) I generate the options for the grid and put the results in $scope.testGridOptions, ex. schema, columns, sorting/grouping/filtering options/etc. This works well and the grid works as expected. However, I actually need to be able to update the grid (schema, columns, data, etc.) based on different things the user can click on. If it was just a few different grid types I'd probably just hide/show them, but this grid needs to be built dynamically. Unfortunately, if I just update testGridOptions the grid doesn't get updated.

Is there a way to force the grid to reload its settings?

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 15 Aug 2014, 12:21 PM
Hi Paul,

Some of the Grid settings cannot be updated on the fly, due to implementation design, performance considerations, etc.

There are two ways to update the Grid settings, which are related to its dataSource (model, schema), and add or remove columns (which is different from showing and hiding of columns).

1. Use autogenerated columns (i.e. do not set any column settings) and use the Grid's setDataSource method. The columns will be generated based on the fields in the new dataSource.

http://docs.telerik.com/kendo-ui/api/web/grid#methods-setDataSource

2. Destroy the Grid, empty its <div> and recreate the widget with the new settings.

http://docs.telerik.com/kendo-ui/getting-started/widgets#destroying-kendo-ui-widgets

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
Paul
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or