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

Nested Template "data" Object Overridden By Parent

1 Answer 270 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Todd
Top achievements
Rank 1
Todd asked on 15 May 2015, 04:10 PM

Hello,

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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 19 May 2015, 09:23 AM
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) \\#")


Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Templates
Asked by
Todd
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or