ClientDetailTemplate: 'Invalid template' when using kendo.toString() in ClientTemplate Column

2 posts, 1 answers
  1. Malcolm
    Malcolm avatar
    29 posts
    Member since:
    Oct 2011

    Posted 14 May 2013 Link to this post

    Dear KendoUI Team!
    I hope you can help me. I got the following problem:
    when using kendo.toString to format a number.

    The following line inside the ClientDetailTemplate for a grid Column leads to an 'invalid template' error:
    columns.Bound(o => o.Price).Title(Strings.di_Price).ClientTemplate("#= kendo.toString(Price, \"n2\") #");
    columns.Bound(o => o.Price).Title(Strings.di_Price).ClientTemplate("#= kendo.toString(Price, 'n2') #");

    while this is OK:
    columns.Bound(o => o.Price).Title(Strings.di_Price).ClientTemplate("#= kendo.toString(Price) #");

    Here is the line in the model

            public decimal Price { get; set; }

    But I want to format the column. In the main grid, I can use .toString() like described. But in the ClientDetailTemplate it fails.
    What can I do to format the output in ClientDetailTemplate?

    Malcolm Howlett
  2. Answer
    Nikolay Rusev
    Nikolay Rusev avatar
    2289 posts

    Posted 15 May 2013 Link to this post

    Hello Malcolm,

    The ClientTemplate string inside template (detail template) must escape the `#` symbols.
    This said the column configuration for the detail grid should become:

    columns.Bound(o => o.Price).Title(Strings.di_Price)
      .ClientTemplate("\\#= kendo.toString(Price, 'n2') \\#");

    Of course the model for the detail grid should have `Price` field.

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