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

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

1 Answer 538 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Malcolm
Top achievements
Rank 1
Malcolm asked on 14 May 2013, 04:17 PM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Nikolay Rusev
Telerik team
answered on 15 May 2013, 07:32 AM
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!
Tags
Grid
Asked by
Malcolm
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or