I have 3 level grid (Hierarchy sample)
I have problems if I want to edit all grids in popup editor.
First level grid open popup edit dialog with no problem but 2 and 3d level grids generate "Invalid template" error when I try to add row.
I tried to run this without EditorTemplate and with editor template with same effect (mean default editor template for my apartment is no good to kendo)
first grid
@(Html.Kendo().Grid<Dispatcher.Models.BlocksVM>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.InhabitatLocationCalculated);
columns.Bound(e => e.Address);
columns.Bound(e => e.NumberOfApartments);
columns.Bound(e => e.Entrances);
columns.Bound(e => e.Stages);
columns.Command(command => { command.Edit().Text(" "); command.Destroy().Text(" "); }).Width(180);
})
.Sortable()
.Pageable()
.Scrollable(s => s.Height("1000px"))
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("Block").Window(w=>w.Title("Добавление / изменение дома")))
.Selectable()
.ClientDetailTemplateId("ApartmentsTemplate")
.HtmlAttributes(new { style = "height:100%;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Blocks_Read", "Clients"))
.Model(model => model.Id(m => m.BlockId))
.Create(action => action.Action("Block_Create", "Clients"))
.Update(action => action.Action("Block_Update", "Clients"))
.Destroy(action => action.Action("Block_Destroy", "Clients"))
.Events(events => events.RequestEnd("cancel"))
)
.Events(events => events.DataBound("dataBound"))
)
and client template
<script id="ApartmentsTemplate" type="text/kendo-tmpl">
@(Html.Kendo().Grid<Dispatcher.Data.Apartment>()
.Name("Apartments_#=BlockId#")
.Columns(columns =>
{
columns.Bound(o => o.Number);
columns.Bound(o => o.Floor);
columns.Bound(o => o.Entrance);
columns.Command(command => { command.Edit().Text(" "); command.Destroy().Text(" "); }).Width(180);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.ClientDetailTemplateId("ClientsTemplate")
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Model(model => model.Id(m => m.ApartmentId))
.Events(events => events.Error("error_handler"))
.Read(read => read.Action("Apartments_Read", "Clients", new { BlockId = "#=BlockId#" }))
.Destroy(action => action.Action("Apartment_Destroy", "Clients"))
.Update(action => action.Action("Apartment_Update", "Clients"))
.Create(action => action.Action("Apartment_Create", "Clients", new { BlockId = "#=BlockId#" }))
)
.Pageable()
.Sortable()
.Selectable()
.ToClientTemplate()
)
</script>
3d level grid shows same behaviour
So when I have NO EditorTemplates for my Apartment model I have error
if I add Apartment.aspx under EditorTemplates like
@model Dispatcher.Data.Apartment
<div class="k-edit-label">
@Html.LabelFor(model => model.Number)
</div>
<div class="editor-field">
@Html.Kendo().TextBoxFor(m => m.Number).HtmlAttributes(new { style = "width:100%;" })
</div>
<div class="k-edit-label">
@Html.LabelFor(model => model.Entrance)
</div>
<div class="editor-field">
@Html.Kendo().TextBoxFor(m => m.Entrance).HtmlAttributes(new { style = "width:100%;" })
</div>
<div class="k-edit-label">
@Html.LabelFor(model => model.Floor)
</div>
<div class="editor-field">
@Html.Kendo().TextBoxFor(m => m.Floor).HtmlAttributes(new { style = "width:100%;" })
</div>
also error.
Now I found that it works then I do have Apartment.aspx under EditorTemplates and file is EMPTY.
In this case it open popup dialog on 2d level grid with standard template.
Also I compared my view with AjaxHierarchyEditing.sln found here in AJAX section and I see absolutely no difference.
also wrong template looks like this (this is generated - from crome debugger - I just added return for readability)
<div class="k-edit-label">
<label for="Number">Номер</label>
</div>
<div class="editor-field">
<input class="k-textbox" data-val="true" data-val-required="Укажите номер квартиры" id="Number" name="Number" style="width:100%;" value="" />
</div>