or
I have a kendo grid with two sub grids. The last subgrid has inline edit. (See code below for grids)
I have the following error method. The first error message displays: "In the error handler method." The second alert says "object [Object]" and the third message says "undefined." Since its undefined the
if(e.errors) statement is not run and no errors are displayed.
I break on the controller and the ModelState.IsValid = false and I see two items that have Errors Count = 1. I have even hardcoded an error like: ModelState.AddModelError("From", "From is required");.
function error_handler(e) { alert("In the error handler method."); alert(e); alert(e.errors); if (e.errors) { alert("Has errors."); var message = "Errors:\n"; $.each(e.errors, function (key, value) { alert("Errors:" + key + value); if ('errors' in value) { $.each(value.errors, function () { message += this + "\n"; }); } }); alert(message); }}Here is the code for the grids:
@(Html.Kendo().Grid<HtramDivision>() .Name("grid") .Columns(columns => columns.Bound(d => d.Name).Title("Divisions")) .ClientDetailTemplateId("templateSub") .HtmlAttributes(new { style = "height:800px;" }) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("Divisions", "Division", new { projectID = Model.ProjectID })) ) .Scrollable())<script id="templateSub" type="text/kendo-tmpl"> @(Html.Kendo().Grid<HtramSubDivision>() .Name("grid_#=DivisionID#") .Columns(columns => { columns.Bound(s => s.Name).Title("SubDivisions"); }) .ClientDetailTemplateId("templateCat") .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("SubDivisions", "SubDivision", new { projectID = Model.ProjectID, divisionID = "#=DivisionID#" })) ) .Sortable() .Scrollable(sc=>sc.Height("")) .ToClientTemplate() )</script> <script id="templateCat" type="text/kendo-tmpl"> @(Html.Kendo().Grid<HtramProjectCategoryResults>() .Name("grid_#=SubDivisionID#") .Columns(columns => { columns.Bound(pcr => pcr.From).Width(80); columns.Bound(pcr => pcr.To).Width(80); columns.ForeignKey(pcr => pcr.CategoryID, (System.Collections.IEnumerable)ViewData["categories"], "CategoryID", "Name").EditorTemplateName("CategoriesDropDownList").Width(300); columns.ForeignKey(pcr => pcr.CategoryValueID, (System.Collections.IEnumerable)ViewData["categoryValues"], "CategoryValueID", "Name").EditorTemplateName("CategoryValueDropDownList").Width(300); columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200); }) .ToolBar(toolbar => toolbar.Create().Text("Add").HtmlAttributes(new { @title = "Add" })) .Editable(editable => editable.Mode(GridEditMode.InLine)) .DataSource(dataSource => dataSource .Ajax() .PageSize(20) .Events(events => events.Error("error_handler")) .Model(model => { model.Id(pcr => pcr.ProjectsCategoryResultsID); model.Field(pcr => pcr.ProjectsCategoryResultsID).Editable(false); }) .Read(read => read.Action("CategoryResultsRead", "Category", new { projectID = Model.ProjectID, subDivisionID = "#=SubDivisionID#" })) .Create(create => create.Action("CategoryResultsCreate", "Category")) .Update(update => update.Action("CategoryResultsUpdate", "Category")) .Destroy(destroy => destroy.Action("CategoryResultsDestroy", "Category")) ) .Sortable() .Scrollable(sc=>sc.Height("")) .ToClientTemplate() )</script>
element.kendoTreeView({ dataSource: data, checkboxes: { name: "checkedData", template: "<input type='checkbox' name='checkedData' value='#= item.text #' />" } });filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#3695b3, endColorstr=#00536e, GradientType=0);-ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#3695b3, endColorstr=#00536e, GradientType=0);<div> @(Html.Kendo().Grid(Model.Items) .Name("GridReportCommerciale") .Columns(columns => { columns.Bound(p => p.Workcentre) .Template(@<div onclick="openVincoli('@item.Workcentre')" class="contentCell" style="font-weight:bold;font-size:11px" >@item.Workcentre</div>) .Title("WC").Width(60); foreach (var sett in Model.SettimaneVisibili) { columns.Template(@<text> @if (item[sett.Clone()] != null && item[sett.Clone()].Diametro > 0) { if (item[sett].Stato == "R") { <div onclick="openCampaign('@item[sett.Clone()].RiferimentoCampagna')" class="contentCell" style="background-color:#FF8C00;"> <div>@string.Format("{0:0.00}", item[sett.Clone()].Diametro)</div> <div>@string.Format("({0:#,##0})", item[sett.Clone()].Quantita)</div> </div> } else { <div onclick="openCampaign('@item[sett.Clone()].RiferimentoCampagna')" class="contentCell" style="background-color:#FFFFE0;"> <div>@string.Format("{0:0.00}", item[sett.Clone()].Diametro)</div> <div>@string.Format("({0:#,##0})", item[sett.Clone()].Quantita)</div> </div> } } else { <div class="contentCell" > <div> </div> <div> </div> </div> } </text>) .HeaderTemplate( @<div> <div>@string.Format("{0:00}-{1:0000}", sett.Clone().NumeroSettimana, sett.Clone().Anno)</div> <div>@string.Format("{0}", sett.Clone().GetDayRange())</div> </div>) .Width(70); } }) .Scrollable() .ToolBar(t=>{ t.Template(@<div class="k-toolbar k-grid-toolbar k-grid-top"> <a class="k-button k-button-icontext " href="/ReportCommerciali?pos=-1"> <span></span> Indietro </a> <a class="k-button k-button-icontext " href="/ReportCommerciali?pos=1"> <span></span> Avanti</a> <span>@Model.VisibleRangeDescription</span> </div>); }) //.Resizable(resize => resize.Columns(true)) //.Reorderable(reorder => reorder.Columns(false)) .HtmlAttributes(new { style = "height: 700px;" }) )</div>