Custom column template not work with Hierarchy Grid

1 Answer 223 Views
Grid
vac
Top achievements
Rank 1
vac asked on 30 Nov 2021, 04:14 PM

look this:

columns.Bound(p => p.Lock).ClientTemplate("<input onclick='return false;' type='checkbox' #= Lock? checked='checked' : ' ' # />");

It's completely normal but I always get  Invalid template

It's just happen with Hierarchy grid, and with normal grid it works fine.

<script id="LoadWeek" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<WorkingWeek>()
            .Name("grid_#=Id#")
            .Columns(columns =>
            {
                another column bound
                columns.Bound(p => p.Lock).ClientTemplate("<input onclick='return false;' type='checkbox' #= datChuan ? checked='checked' :'' # />");
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(5)
                .Read(read => read.Action("HierarchyBinding_Week", "WeeklyProgress", new { WorkingMonthId = "#=Id#" }))
            )
            .Pageable()
            .Sortable()
            .ToClientTemplate()
    )
</script>
How can I edit the template column as I want with Hierarchy grid?

1 Answer, 1 is accepted

Sort by
1
Alexander
Telerik team
answered on 03 Dec 2021, 09:01 AM

Hi,

Thank you for the provided information and code snippets.

Such errors will normally be present if there is an issue with the Template Syntax. When using nested templates, the hash literals needs to be escaped. This is outlined in step 7 in Setting the Client Hierarchy article.

For example:

.ClientTemplate("<input onclick='return false;' type='checkbox' \\#= Lock? checked='checked' : ' ' \\# />");

Additionally, you can review the Creating Inline Templates article for additional information regarding the usage of templates.

I hope this helps.

Regards,
Alexander
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
vac
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or