单击编辑按钮时弹出窗口的工作原理以及如何在弹出窗口中显示三个Combobox。我真的对以下代码感到困惑
Client side Code
//show server errors if any
function error_handler(e) {
if (e.errors) {
var message = "Errors:\n\n";
$.each(e.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n\n";
});
}
});
alert(message);
}
}
@(Html.Kendo().Grid(Model)
.Name("SchoolGrid")
.Columns(columns =>
{
columns.Bound(p => p.SchoolID).Width("80px");
columns.Bound(p => p.Name);
columns.Bound(p => p.Campus).Width("90px");
columns.Bound(p => p.StateCode).Width("90px");
columns.Bound(p => p.SectorCode).Width("95px");
columns.Bound(p => p.MDISurveyStartDate).ClientTemplate("#= (MDISurveyStartDate == null) ? 'Not Set' : kendo.toString(MDISurveyStartDate, 'dd/MM/yyyy') #").Width("90px");
columns.Bound(p => p.MDISurveyEndDate).ClientTemplate("#= (MDISurveyEndDate == null) ? 'Not Set' : kendo.toString(MDISurveyEndDate, 'dd/MM/yyyy') #").Width("90px");
columns.Command(command => { command.Edit(); command.Destroy(); }).Width("190px").HtmlAttributes(new { style = "text-align:center" });
})
.ToolBar(tb => tb.Create().Text("Add New School"))
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("EditSchool").Window(w => w.Title("Add/Edit School Details").Name("editWindow").Width(600)))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.ClientID))
.Events(e => e.Error("error_handler"))
.Read("Read_Schools", "School")
.Update("Update", "School")
.Create("Create", "School")
.Destroy("Destroy", "School")
)
)
Server Side Code:-
[HttpPost]
public ActionResult Update([DataSourceRequest] DataSourceRequest request, School school)
{
try
{
if (ModelState.IsValid)
{
string errMsg = "";
if (!_Service.UpdateSchool(school, out errMsg))
ModelState.AddModelError("UpdateSchool", errMsg);
}
}
catch (Exception ex)
{
ModelState.AddModelError("UpdateSchool", ex.Message);
}
return Json(ModelState.ToDataSourceResult());
}