我正在使用 Kendo UI ASP.Net MVC - 网格 - 批量编辑,
单击“保存”后。数据成功保存在数据库中。
但是“kendo.web.min.js”抛出错误“Microsoft JScript 运行时错误:预期';'”
@model IEnumerable<EOL.RecOil.Models.ControllerActionViewModel>
@using Kendo.Mvc.UI;
<div>
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.ID).Visible(false);
columns.Bound(p => p.ControllerName);
columns.Bound(p => p.ActionName);
columns.Bound(p => p.HasAccess);
columns.Bound(p => p.UserAccessID).Visible(false);
columns.Bound(p => p.ControllerID).Visible(false);
columns.Bound(p => p.ActionID).Visible(false);
})
.Filterable()
.Groupable()
.Editable(editable => editable.Mode(GridEditMode.InCell))
.ToolBar(toolBar => { toolBar.Save(); })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.Events(events => events.Error("error"))
.Update(update => update.Action("Edit","ControllerActions"))
.ServerOperation(false)
.Model(x =>
{
x.Id(p => p.ID);
x.Field(p => p.ControllerName).Editable(false);
x.Field(p => p.ActionName).Editable(false);
x.Field(p => p.HasAccess).Editable(true);
})
)
)
</div>
[HttpPost]
public ActionResult Edit([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable<ControllerActionViewModel> controllerActionViewModel)
{
try
{
if (controllerActionViewModel != null && ModelState.IsValid)
{
foreach (var item in controllerActionViewModel)
{
db.Database.ExecuteSqlCommand("SaveUserAccess @UserID,@ControllerID,@ActionID,@UserAccessID,@HasAccess",
new SqlParameter("UserID", item.UserID),
new SqlParameter("ControllerID", item.ControllerID),
new SqlParameter("ActionID", item.ActionID),
new SqlParameter("UserAccessID", item.UserAccessID),
new SqlParameter("HasAccess", item.HasAccess)
);
}
}
}
catch (Exception ex)
{
Helper.SaveError(ex.InnerException.InnerException.Message, "ControllerActions", "Edit");
ModelState.AddModelError(string.Empty, ex.InnerException.InnerException.Message);
}
return Json(new[] { controllerActionViewModel }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
}