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:
    (BAD:)
    columns.Bound(o => o.Price).Title(Strings.di_Price).ClientTemplate("#= kendo.toString(Price, \"n2\") #");
    or
    columns.Bound(o => o.Price).Title(Strings.di_Price).ClientTemplate("#= kendo.toString(Price, 'n2') #");

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

    Here is the line in the model

            [DataType("Number")]
            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?

    brgds
    Malcolm Howlett
  2. Answer
    Nikolay Rusev
    Admin
    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.

    Regards,
    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