Refresh Parent Grid After sub-grid save

3 posts, 1 answers
  1. AP
    AP avatar
    224 posts
    Member since:
    Apr 2010

    Posted 24 Sep 2015 Link to this post

    I have a hierarchical grid, containing a list of records, with their associated actions.

     When an action is inserted, the data repository will adjust the status of the master record, according to the action type that has been inserted.  This works, however I'm having difficulty refreshing the master grid to reflect the change in status.

    I have put a handler on the action grids (the sub grid) save event, however this fires before the database change has been saved, so the change to the master grids data isn't reflected?

     What event can I handle to refresh the master grid once the data has been saved?

    The code is:-


                            .Events(e => e.Edit("onSubEdit"))
                           .Columns(columns =>
                               columns.Bound(o => o.ID).Title("ID");
                               columns.Bound(o => o.ActionType).Title("Type").ClientTemplate("<span>\\#=ActionTypeDescription\\#</span>").Filterable(f => f.UI("actionTypeFilter"));
                               columns.Bound(o => o.Description).Title("Description");
                               columns.Command(command => { command.Edit(); command.Destroy(); });
                           .Filterable(f => f
       .Operators(o => o
       .ForNumber(str => str.Clear()
                             .ToolBar(commands => commands.Create())
                           .Editable(editable => editable
                           .DataSource(dataSource => dataSource
                               .Events(e => e.Error(@<text> function(e){subError(e,"ActionsGrid_#=ID#")} </text>))
                                .Model(m => m.Id(p => p.ID))
                               .Read(read => read.Action("RD_Actions", "ChangeRequests", new { ChangeRequestID = "#= ID #" }))
                               .Create(create => create.Action("InsertAction", "ChangeRequests", new { CRID = "#= ID #" }))
                               .Update(update => update.Action("UpdateAction", "ChangeRequests"))
                               .Destroy(delete => delete.Action("DeleteAction", "ChangeRequests"))
                               .Pageable(p => p.Refresh(true))

     The handler is:-


    function actionSave()
          var grid = $('#Grid').data("kendoGrid");


  2. Answer
    Kiril Nikolov
    Kiril Nikolov avatar
    2596 posts

    Posted 28 Sep 2015 Link to this post

    Hello AP,

    I would suggest you to use the dataSource sync event that will be fired when the record is updated, and there you can refresh the parent grid. Please test it out and let me know if it helps.

    Kiril Nikolov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. AP
    AP avatar
    224 posts
    Member since:
    Apr 2010

    Posted 28 Sep 2015 in reply to Kiril Nikolov Link to this post

    That's worked. Thanks.
Back to Top