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();
}