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

Column ClientTemplate inside of a Grid detail template

4 Answers 1754 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dimitrij
Top achievements
Rank 1
Dimitrij asked on 14 Apr 2015, 03:05 PM

Following problem: I've got a "detail" grid as element of a ClientDetailTemplate of a "master" grid. One column ("IsActive" in this example) in the detail grid should get a ClientTemplate, whose value is dependent on a property from the detail grid's data:

@(Html.Kendo().Grid<MasterEntity>()
    .Name("masterGrid")
    .Columns(columns =>
    {
        ...
    })
    .ClientDetailTemplateId("detailsTemplate")
    .DataSource(...))
)

<script id="detailsTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<DetailEntity>()
        .Name("detailGrid_#=Id#")
        .Columns(columns =>
        {
            columns.Bound(p => p.IsActive).ClientTemplate("#= IsActive #");
        })
        .DataSource(...)
        .ToClientTemplate()
    )
</script>

 

Unfortunately, the expression "#= IsActive #" in the detail template cannot be evaluated correctly. The "scope" for the template is set to the master grid - thus I can add an expression to a property of the master grid, but not the detail grid. How can I achieve to set a ClientTemplate for the detail grid column with property expressions to the client grid data?

 

Thanks, Dimitrij

4 Answers, 1 is accepted

Sort by
0
Dimitrij
Top achievements
Rank 1
answered on 15 Apr 2015, 05:57 AM

Ok, I finally figured it out: http://www.telerik.com/forums/column-clienttemplate-in-clientdetailtemplate

I had to escape the "#" characters, now it works: "\\#= IsActive \\#".

 

 ~ Dimitrij

0
Accepted
Dimiter Madjarov
Telerik team
answered on 15 Apr 2015, 10:46 AM

Hello Dimitrij,

You are right. Escaping the hash tag symbols is the correct way to go here.

Regards,
Dimiter Madjarov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Beheer
Top achievements
Rank 1
answered on 29 Sep 2017, 02:41 PM

Hi , because my Client template use javascript to format the text to be render,

I am following a very common approach like

....

columns.Bound(o => o.Price).ClientTemplate("#=getTemplateForCurrencyColumn(data)#");

....

 

If I use "data" keyword I can access the parent datasource.

ff the name of collection for the list is "items" I can access the collection aswell (.ClientTemplate("#=getTemplateForCurrencyColumn(items)#");)

What I cannot reason is how to get the dataItem in context or even the value of the price for the column.

how can I can accomplish that?

 

Thanks in advance.

0
Stefan
Telerik team
answered on 03 Oct 2017, 06:57 AM
Hello, Beheer,

The value for the specific row can be added using the field name, for example, "getTemplateForCurrencyColumn(Price)"

If the ClientTemplate is used inside a ClientDetailTemplateId, then expand has to be done as suggested in one of the previous posts in this thread.

Regards,
Stefan
Progress Telerik
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
Dimitrij
Top achievements
Rank 1
Answers by
Dimitrij
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Beheer
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or