Grid Detailtemplate Conclusion

2 posts, 1 answers
  1. Michael
    Michael avatar
    2 posts
    Member since:
    Aug 2013

    Posted 05 Sep 2013 Link to this post

    Hello everybody

    I have a grid with a detailtemplate. This detailtemplate contains also a grid.
    My parent grid refers to an Edition-Model which contains many Articles. When the user expands an Edition-Row, the detailgrid contains all correct Articles.

    The problem now is, that i want to check, if one Article is allready read by the user. So i want to insert a conclusion, that i can show one or another value in a column of the detailgrid.

    On this website, i found the template-syntax: http://docs.kendoui.com/getting-started/framework/templates/overview#template-syntax

    But it doesnt work fine. In the detailgrid the conclusion checks every time the parent-data (Edition) and not the detaildata (Article).

    My ClientTemplate (for the detail grid)
    columns.Bound(c => c.IsRead).ClientTemplate("" +
                    "#if(IsRead== true) {#" +
                    "Read"+
                    "#} else{#" +
                    "Not Read +
                    "#}#")
                    .Title("State").Width(120);

    When i put an output in the ClientTemplate as shown in the link above, then the Template renders the correct data (with the \\# syntax)

    Example (clienttemplate for the detail grid):
    columns.Bound(c => c.IsRead).ClientTemplate("" +
                    "#if(IsRead== true) {#" +
                    "#=data.Id#"+      // Shows parent Id
                    "#} else{#" +
                    "\\#=data.Id\\# +     // Shows the correct id from the detail row
                    "#}#")
                    .Title("State").Width(120);
    My question now: How can I check the data of the detailrow in a conclusion??

    Edit:
    For better understanding: I have the sam CSharp - Model in both Grids. When i make two diffrent models, then it is the same situation. Only one diffrence: Javascript-Console says: Undifined Property (for IsRead). Because my actual Edition - Model has no property named IsRerad.

    Thanks and have a nice day
    MJ
  2. Answer
    Daniel
    Admin
    Daniel avatar
    2214 posts

    Posted 09 Sep 2013 Link to this post

    Hello Michael,

    Since the ClientTemplate in the detail is a nested template, the "#" characters should be escaped so that the expression is evaluated in the correct context:

    columns.Bound(c => c.IsRead).ClientTemplate("" +
                    "\\#if(IsRead== true) {\\#" +
                    "Read"+
                    "\\#} else{\\#" +
                    "Not Read +
                    "\\#}\\#")
                    .Title("State").Width(120);
    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top