For some strange reason, the GroupName column returns a null value to the controller even though I enter a value into the grid UI. The GroupDescription column passes the entered value successfully. Both columns are strings except GroupName is a required field in the GroupVM view model. The work around is that I have to use a clientemplate for GroupName (see below)
THIS WORKS: columns.Bound(p => p.GroupName).ClientTemplate("#=GroupName #").Title("Group Name");
THIS DOES NOT WORK: columns.Bound(p => p.GroupName).Title("Group Name");
@model IEnumerable<
ViewModels.GroupVM
>
@(Html.Kendo().Grid<
ViewModels.GroupVM
>()
.Name("GroupGrid")
.ToolBar(toolbar => toolbar.Create().Text("Create"))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.Columns(columns =>
{
columns.Bound(p => p.GroupId).Hidden();
columns.Bound(p => p.GroupName).ClientTemplate("#=GroupName #").Title("Group Name");
columns.Bound(p => p.GroupDescription).Title("Group Description");
columns.Command(command => { command.Edit(); }).Width(200);
})
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(p => p.GroupId);
})
.Events(events => events.Error("error_handler"))
.Create(update => update.Action("ManageGroups_C", "Group"))
.Read(read => read.Action("ManageGroups_R", "Group"))
.Update(update => update.Action("ManageGroups_E", "Group"))
)
)
<
script
type
=
"text/javascript"
>
function error_handler(e) {
if (e.errors) {
var message = "Errors:\n";
$.each(e.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n";
});
}
});
alert(message);
}
}
</
script
>