Column ClientTemplate inside of a Grid detail template

5 posts, 1 answers
  1. Dimitrij
    Dimitrij avatar
    8 posts
    Member since:
    Apr 2015

    Posted 14 Apr 2015 Link to this post

    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

  2. Dimitrij
    Dimitrij avatar
    8 posts
    Member since:
    Apr 2015

    Posted 15 Apr 2015 in reply to Dimitrij Link to this post

    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

  3. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2312 posts

    Posted 15 Apr 2015 Link to this post

    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.

     
  4. Beheer
    Beheer avatar
    6 posts
    Member since:
    Nov 2013

    Posted 29 Sep 2017 Link to this post

    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.

  5. Stefan
    Admin
    Stefan avatar
    3072 posts

    Posted 03 Oct 2017 Link to this post

    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.
Back to Top