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

Client Template not defined when contained in ClientDetailTemplate

1 Answer 864 Views
Grid
This is a migrated thread and some comments may be shown as answers.
GCS
Top achievements
Rank 1
GCS asked on 03 Jul 2014, 03:43 PM
I have a grid that uses a ClientDetailTemplate.  The template is defined as: 

<script id="plan_client_template" type="text/kendo-tmpl">
 
    @(Html.Kendo().Grid<Rep.Models.BuildingChangeValidationViewModel>()
          .Name("CVGrid")
          .Scrollable()
          .Selectable()
          .Editable(editable => editable.Mode(GridEditMode.InLine))
          .Columns(columns =>
          {
              columns.Bound(b => b.Field);
              columns.Bound(b => b.BuildingChangeValidationStatusType).ClientTemplate("#=BuildingChangeValidationStatusType.Value#").Width(250);
              columns.Command(command => command.Custom("Update").Click("updateValidation"));
              columns.Command(command => { command.Edit(); }).Width(172);
          })
          .DataSource(dataSource => dataSource
              .Ajax()
                .Model(model =>
                {
                    model.Id(b => b.BuildingId);
                    model.Field(b => b.BuildingChangeValidationStatusType).DefaultValue(
                        ViewData["defaultBuildingChangeValidationStatuses"] as Rep.Common.LookupItem);
                })
              .PageSize(5)
            .Read(read => read.Action("BuildingValidations_Read", "Plan", new { buildingId = 0 }))
            .Update(update => update.Action("BuildingValidations_Update", "Plan"))
 
          )
          .ToClientTemplate()
    )
</script>

Note that a column uses a ClientTemplate.  The client template is simply a dropdown list. However, the grid is unable to locate the client template and instead returns the error:  "Uncaught ReferenceError: BuildingChangeValidationStatusType is not defined"

However, If I remove the detail grid from the Client Detail Template and put it in a div alongside the parent grid, and remove the ".ToClientTemplate()" call, it works perfectly. So there's something about placing a grid containing a column client template inside of a parent grid's client detail template that make it not work.  Any ideas? 

1 Answer, 1 is accepted

Sort by
1
Dimiter Madjarov
Telerik team
answered on 04 Jul 2014, 07:33 AM
Hello Dave,


The reason for the issue is that the master Grid is trying to parse the template, which is causing an error, stating that the property was not found in the Grid model. As a solution you should escape the hash tag symbols from the template syntax, so that it is parsed by the child Grid only.
E.g.
columns.Bound(b => b.BuildingChangeValidationStatusType).ClientTemplate("\\#=BuildingChangeValidationStatusType.Value\\#");

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
GCS
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or