Refresh Parent Grid After sub-grid save

3 posts, 1 answers
  1. AP
    AP avatar
    187 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:-

     

    @(Html.Kendo().Grid<SimpleChangeControl.Models.View_Action>()
                           .Name("ActionsGrid_#=ID#")
                            .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
       .Extra(false)
       .Operators(o => o
       .ForNumber(str => str.Clear()
       .IsEqualTo("Equals"))))
                             .ToolBar(commands => commands.Create())
                           .Editable(editable => editable
                       .Mode(GridEditMode.PopUp))
                           .DataSource(dataSource => dataSource
                               .Ajax()
                               .Events(e => e.Error(@<text> function(e){subError(e,"ActionsGrid_#=ID#")} </text>))
                                .Model(m => m.Id(p => p.ID))
                               .PageSize(10)
     
                               .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"))
                                
                               )
                               .Filterable()
                               .Events(e=>e.Save("actionSave"))
                               .Pageable(p => p.Refresh(true))
     
                               .ToClientTemplate())

     The handler is:-

     

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

     

  2. Answer
    Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2566 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.

    Regards,
    Kiril Nikolov
    Telerik
    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. UI for ASP.NET MVC is VS 2017 Ready
  4. AP
    AP avatar
    187 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