Title says it all. I am editing a record inline. When I hit update, the request to the server occurs, the record is saved and the response is returned. However, the Grid does not acknowledge the fact that the AJAX request was successful. So the Grid stays in edit-mode. If I cancel then refresh the grid, the row shows up as it should (saved). No errors are occurring on the server or client.
I'm using the ASP.NET MVC Wrappers - AJAX.
I'm using the ASP.NET MVC Wrappers - AJAX.
<
div
style
=
"width: 700px"
>
@(Html.Kendo().Grid<
RoleGridModel
>()
.Name("grdRoles")
.Columns(columns =>
{
columns.Bound(r => r.Name).Width(200);
columns.Bound(r => r.Description).Width(300);
columns.Command(command => {
if (security.CanAdd || security.CanUpdate) command.Edit();
if (security.CanDelete) command.Destroy();
}).Width(200);
})
.Groupable(grouping => grouping
.Enabled(false))
.Events(events => { if (security.CanAdd && !security.CanUpdate) events.DataBound("function() { this.table.find('.k-grid-edit').hide(); }"); })
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(r => r.RoleId))
.Events(events => events.Error("error_handler"))
.Read(read => read.Action("Index", "Roles", new { area = "Setup" }))
.Create(create => create.Action("Create", "Roles", new { area = "Setup" }))
.Update(update => update.Action("Edit", "Roles", new { area = "Setup" }))
.Destroy(destroy => destroy.Action("Delete", "Roles", new { area = "Setup" }))
.Sort(sort => sort.Add(r => r.Name).Ascending())
.PageSize(10))
.Filterable(filtering => filtering
.Enabled(true))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable(paging => paging
.Enabled(true)
.Info(true)
.PageSizes(false)
.Refresh(true))
.Scrollable(scrolling => scrolling
.Enabled(false)
.Height(400)
.Virtual(false))
.Sortable(sorting => sorting
.Enabled(true)
.AllowUnsort(false)
.SortMode(GridSortMode.SingleColumn))
.ToolBar(toolbar => { if (security.CanAdd) toolbar.Create(); })
)
</
div
>
[HttpPost]
public
ActionResult Edit([DataSourceRequest] DataSourceRequest request, RoleGridModel model)
{
if
(ModelState.IsValid && model !=
null
)
{
try
{
Role r = Mapper.Map<RoleGridModel, Role>(model);
r.AppContext =
this
.AppContext;
r.SubscriberId =
this
.AppContext.SelectedSubscription.SubscriberId;
r.SubscriptionId =
this
.AppContext.SelectedSubscription.SubscriptionId;
r.ModifyDate = DateTime.UtcNow;
r.IsNew =
false
;
r.IsMarkedForDelete =
false
;
r.HasChanges =
true
;
r.Save();
}
catch
(Exception ex)
{
LogException(ex);
ModelState.AddModelError(
""
,
"Unable to update role. "
+ ex.Message);
}
}
return
Json(ModelState.ToDataSourceResult());
}