Nested Template "data" Object Overridden By Parent

2 posts, 1 answers
  1. Todd
    Todd avatar
    5 posts
    Member since:
    Aug 2012

    Posted 15 May 2015 Link to this post


    I am trying to format a cell in a grid differently based another cell in the row's value (i.e. format a currency cell with its proper currency symbol from another column, with multiple different currencies in the same grid).

    The column that must be formatted is in a grid that is part of a client detail template for another grid. The way I have worked out to accomplish the formatting in a top level grid is a client template on the column that calls a Javascript function. I pass the implicitly defined "data" object in the client template to the function to access the row data.

    ...ClientTemplate("#= formatCurrency(data) #")

    The problem is that, for a child grid in a client detail template, the data that I receive in the function is not the row of the child grid, but the row of the parent grid.

    I have attached models, views, and controllers demonstrating the issue. I am using C# MVC and the Razor view engine, but if this is not possible with razor, I could switch to HTML5/Javascript.

    Thanks for any help you can provide.

  2. Answer
    Daniel avatar
    2109 posts

    Posted 19 May 2015 Link to this post

    Hello Todd,

    You should escape the "#" characters when using nested templates in order to prevent evaluating the expression in the master template context e.g.
    ClientTemplate("\\#= formatCurrency(data) \\#")

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top