사용 Razor MVC 4.0
필자는 모델에 지정된대로 'Name
'의 필수 필드가있는보기가 있습니다. 나는이 Kendo Grid/EditMode InLine/Server bound Data source
@KENDO UI 편집 가능한 InLine Grid Server 바인딩 유효성 검사 메시지가 표시되지 않음
(아래 참조)이 (Html.Kendo(). 그리드 (모델)
.Name("Grid")
.Events(e => e.Edit("gridChange"))
.Columns(columns =>
{
columns.Bound(p => p.Id).Hidden(); //Create a column bound to the "ProductID" property
columns.Bound(p => p.Name).Width(120); //Create a column bound to the "ProductName" property
columns.Bound(p => p.SortValue).Width(80).EditorTemplateName("SortNumericTextBox"); //Create a column bound to the "UnitPrice" property
columns.Bound(p => p.Active).Width(100);//Create a column bound to the "UnitsInStock" property
columns.Command(command => command.Edit()).Width(100);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Server()
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.Name).Editable(true);
model.Field(p => p.SortValue);
model.Field(p => p.Active);
})
// Configure CRUD -->
.Create(create => create.Action("Create", "MonitorType"))
.Read(read => read.Action("Index", "MonitorType"))
.Update(update => update.Action("Edit", "MonitorType"))
.PageSize(5)
)
.Pageable() //Enable paging
)
컨트롤러 (HTTP) 편집에서
과 ModelState.IsValid
(대한 확인을 만들기 그것은 거짓 ... 이름이) 비어있는 경우 없음 업데이트
[HttpPost]
public ActionResult Create(MonitorType monitortype)
{
if (ModelState.IsValid)
{
unitOfWork.MonitorTypeRepository.Insert(monitortype);
unitOfWork.Save();
return RedirectToAction("Index");
}
//GridRouteValues() is an extension method which returns the
//route values defining the grid state - current page, sort expression, filter etc.
RouteValueDictionary routeValues = this.GridRouteValues();
return RedirectToAction("Index", routeValues);
}
그리드에 반환을 발생하지 그러나 - 확인 메시지가 표시 '하지'입니다
.어떻게 유효성 확인 메시지를 표시합니까?
문제는 오류 이벤트를 사용할 수없는 경우에 서버 바인딩 그리드에 관한 것이다. – msulis