Reset/Reload grid after it has initialized

2 posts, 0 answers
  1. Paul
    Paul avatar
    6 posts
    Member since:
    Feb 2012

    Posted 13 Aug 2014 Link to this post

    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?
  2. Dimo
    Admin
    Dimo avatar
    8467 posts

    Posted 15 Aug 2014 Link to this post

    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!
     
Back to Top