I have a grid that successfully inserts and deletes, however, after I perform an insert the inline edit remains open. If I hit cancel it does not display the new data; I have to refresh the page to see it in the grid.
Here is my code:
<div
class
=
"k-grid"
>
@(Html.Kendo().Grid<GasModel>()
.Name(
"manageGasesGrid"
)
.AutoBind(
true
)
.Columns(columns =>
{
columns.Bound(p => p.gasName).Title(
"Name"
);
columns.Bound(p => p.formula).Title(
"Formula"
);
columns.Bound(p => p.gasID).Title(
"ID"
).Hidden();
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(190);
})
.Events(e => e
.Edit(
"onEdit"
)
)
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Sortable(sortable => sortable.SortMode(GridSortMode.MultipleColumn))
.Filterable()
.Reorderable(r => r.Columns(
true
))
.ColumnMenu()
.Scrollable(s => s.Endless(
true
))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(
"gasID"
))
.ServerOperation(
false
)
.Read(read => read.Action(
"Gases_ReadAsync"
,
"Gas"
))
.Create(create => create.Action(
"Gases_CreateAsync"
,
"Gas"
,
"gasData"
))
.Update(update => update.Action(
"Gases_UpdateAsync"
,
"Gas"
,
"gasData"
))
.Destroy(destroy => destroy.Action(
"Gases_DestroyAsync"
,
"Gas"
,
"gasData"
))
)
)
</div>
<script>
function
gasData(e) {
return
{
gasID: id,
gasName: name,
formula: gasFormula
}
}
function
onEdit(e) {
var
id =
this
.gasID
var
name =
this
.gasName
var
gasFormula =
this
.formula
}
</script>