Seeing an odd issue trying to setup some inline editing using the Grid controller. The Grid displays correctly and functions correctly until I try to perform an edit. When I click the edit button, make edits and then press update, the line comes back with empty values.
Upon inspection, the model being passed to the controller ActionResult is null (expect for ID and date). Code below. Took a look at some of the null threads and not seeing a common denominator. Any thoughts:
Grid Control:
@(Html.Kendo().Grid(Model)
.Name("commissionGrid")
.Columns(columns =>
{
columns.Bound(p => p.CommissionId);
columns.Bound(p => p.TenantId);
columns.Bound(p => p.SimpleName);
columns.Bound(p => p.StartDate);
columns.Bound(p => p.CustomerName);
columns.Bound(p => p.CustomerNumber);
columns.Command(command =>
{
command.Edit();
}).Title("Commands");
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Navigatable()
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.PageSize(10)
//.ServerOperation(false)
.Model(model => model.Id(p => p.CommissionId))
.Update(update => update.Action("EditingInline_Update", "Commissions"))
)
)
Controller:
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult EditingInline_Update([DataSourceRequest] DataSourceRequest request, CommissionViewModel commissionViewModel)
{
if
(commissionViewModel !=
null
&& ModelState.IsValid)
{
using
(var test =
new
CommissionContext())
{
try
{
var entity =
new
Commission();
entity.CommissionId = commissionViewModel.CommissionId;
entity.CustomerName = commissionViewModel.CustomerName;
entity.CustomerNumber = commissionViewModel.CustomerNumber;
entity.SimpleName = commissionViewModel.SimpleName;
entity.StartDate = commissionViewModel.StartDate;
entity.TenantId = commissionViewModel.TenantId;
test.Commissions.Attach(entity);
test.Entry(entity).State = EntityState.Modified;
test.SaveChanges();
}
catch
(System.Data.Entity.Validation.DbEntityValidationException v)
{
Console.WriteLine(
"Exception is {0}"
, v);
}
}
}
return
Json(
new
[]{commissionViewModel}.ToDataSourceResult(request, ModelState));
}