This is a migrated thread and some comments may be shown as answers.

Editor template in nested grid

3 Answers 250 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dina
Top achievements
Rank 1
Dina asked on 19 Dec 2016, 09:02 PM

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">&#x41D;&#x43E;&#x43C;&#x435;&#x440;</label>
</div>
<div class="editor-field">    
<input class="k-textbox" data-val="true" data-val-required="&#x423;&#x43A;&#x430;&#x436;&#x438;&#x442;&#x435; &#x43D;&#x43E;&#x43C;&#x435;&#x440; &#x43A;&#x432;&#x430;&#x440;&#x442;&#x438;&#x440;&#x44B;" id="Number" name="Number" style="width:100%;" value="" />
</div>

3 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 22 Dec 2016, 01:18 PM
Hi Dima,

Based on the description it would be hard to determine why are you experiencing such behavior. Please open a formal support ticket and attach a small sample in which these problems can be reproduced. Once we can replicate them on our side we should be able to quickly find their root cause.

Regards,
Angel Petrov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
answered on 03 Feb 2017, 03:32 PM

Same problem here / is it the same problem as in ASP.NET MVC 5 and the AntiXssEncoder?

http://www.telerik.com/forums/template-compile-error---invalid-template

robert

0
Angel Petrov
Telerik team
answered on 08 Feb 2017, 11:36 AM
Hello,

Indeed this may be one cause for the issue. If the suggestion in the related forum thread does not resolve the matter I suggest sending us a small sample that we can inspect.

Regards,
Angel Petrov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Dina
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Share this question
or