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

Refresh Parent Grid After sub-grid save

2 Answers 312 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AP
Top achievements
Rank 1
Iron
Iron
Veteran
AP asked on 24 Sep 2015, 10:52 AM

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 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 28 Sep 2015, 07:33 AM

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
0
AP
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 28 Sep 2015, 07:55 AM
That's worked. Thanks.
Tags
Grid
Asked by
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Kiril Nikolov
Telerik team
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or