I set up a simple grid like this using the Razor syntax:
The problem is that the .Update(...) in the DataSource doesn't expose the callback that the underlying KendoUI does:
Since the transport.update (in the JavaScript) are passed through to the $.ajax handler, we can wire up to success and error, but can't via the MVC. We can do this after the fact, but it's not expected behavior. Can we get this added to future versions of the MVC package?
@(Html.Kendo().Grid<
VideoGames.Game
>(Model)
.Name("theGrid")
.Columns(c =>
{
c.Bound(p => p.Name).Width(200);
c.Bound(p => p.Price).Format("{0:c}").Width(100);
c.Bound(p => p.Genre).Width(100);
c.Bound(p => p.ImageUrl).ClientTemplate("<
img
src
=
'#= ImageUrl #'
alt
=
''
/>").Width(150);
c.Command(cmd => { cmd.Edit(); });
})
.Editable(editable => editable.Mode(Kendo.Mvc.UI.GridEditMode.InCell))
.Pageable()
.ToolBar(c => c.Save())
.DataSource(d => d.Ajax()
.Model(m => m.Id(p => p.Name))
.Update(c => c.Action("UpdateGame", "Home")))
)
The problem is that the .Update(...) in the DataSource doesn't expose the callback that the underlying KendoUI does:
$(
"#theGrid"
).kendoGrid({
dataSource: {
data: data,
batch:
true
,
schema: {
model: {
id:
"GameID"
,
fields: {
GameID: { editable:
false
, nullable:
true
},
Name:
"Name"
,
Price: { type:
"number"
},
ReleaseDate: { type:
"date"
},
Genre:
"Genre"
,
Rating:
"Rating"
,
}
}
}
},
transport: {
update: {
url:
"/home/updategame"
,
success: onUpdateSuccess,
error: onUpdateError
}
}
toolbar: [
"Save"
],
height: 400,
editable:
true
,
scrollable:
true
,
columns: [
{
field:
"Name"
,
title:
"Title"
},
{
field:
"Price"
,
title:
"Price"
,
format:
'{0:c}'
},
{
field:
"ReleaseDate"
,
title:
"Rel Date"
,
template:
'#= kendo.toString(ReleaseDate,"MM/dd/yyyy") #'
},
{
field:
"Genre"
},
{
field:
"Rating"
},
],
});
Since the transport.update (in the JavaScript) are passed through to the $.ajax handler, we can wire up to success and error, but can't via the MVC. We can do this after the fact, but it's not expected behavior. Can we get this added to future versions of the MVC package?