我有一个启用了弹出编辑功能的kendo网格。它不会在更新时触发控制器方法,这是我的代码:
@(Html.Kendo().Grid<Trabaho.Model.Models.ProfileApplicationSubset>()
.Name("Assessment")
.Columns(columns =>
{
columns.Bound(c => c.Position).Width(200).Groupable(true);
columns.Bound(c => c.FirstName).Width(150).Groupable(false);
columns.Bound(c => c.MiddleName).Width(150).Groupable(false);
columns.Bound(c => c.LastName).Width(150).Groupable(false);
columns.Bound(c => c.DesiredSalary).Width(150).Groupable(false);
columns.Bound(c => c.Email).Width(150).Groupable(true);
columns.Bound(c => c.Mobile).Width(150).Groupable(false);
columns.Bound(p => p.Region).Width(300);
columns.Bound(p => p.Province).Width(300);
//columns.Bound(c => c.Region).Width(150);
//columns.Bound(c => c.Province).Width(150);
columns.Bound(c => c.City).Width(150);
columns.Bound(c => c.Barangay).Width(150);
columns.Bound(c => c.Gender).Width(150);
columns.Bound(c => c.Recruiter).Width(150).Groupable(true);
columns.Command(command => { command.Edit(); }).Width(160);
})
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.ToolBar(tools => tools.Excel())
.Navigatable()
.Pageable(page => page
.ButtonCount(5)
.PageSizes(new[] { 50, 100, 500,1000 })
.Refresh(true))
.Sortable()
.Scrollable()
.Groupable()
.Filterable()
.Reorderable(r => r.Columns(true))
.Resizable(r => r.Columns(true))
.ColumnMenu()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(500)
.Read(read => read.Action("_GetForAssessment", "DashBoard"))
.Events(events => events.Error("error_handler"))
.Model(model => { model.Id(p=>p.ApplicationId); model.Field(p => p.ApplicationId); })
.Update(update => update.Action("_Assessment", "DashBoard"))
.Update(read => read.Type(HttpVerbs.Post))
)
)
<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);
}
}
在控制器方法中,我有更新和阅读的这些操作
public ActionResult _GetForAssessment([DataSourceRequest] DataSourceRequest request)
{
var user = GetLinkedProfile(true);
var jsons = _applicationService.GetApplicantsForAssesments("Metro Manila").ToList();
return Json(jsons.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult _Assessment([DataSourceRequest] DataSourceRequest request, ProfileApplicationSubset model)
{
if (model == null || !ModelState.IsValid)
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
var jobApp = _applicationService.Find(model.ApplicationId);
jobApp.EmploymentStatus = model.ApplicationStatus;
jobApp.ObjectState = ObjectState.Modified;
_applicationService.Update(jobApp);
_unitOfWork.SaveChanges();
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
控制器名称为DashBoard,控制台窗口显示没有错误但更新方法中的断点未命中.. 谁能告诉我配置有什么问题?