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

HTML rendering template syntax not working

4 Answers 460 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sebastian
Top achievements
Rank 1
Sebastian asked on 27 Apr 2015, 08:53 AM

Hello,

I need to render HTML content inside some grid cells. So i used the #= # syntax to test if the content is rendered correctly. I embedded the field into <p>-tags to test the simplest case of HTML contents so that it looks like: #= <p>fieldName</p> #

The result is a JavaScript error saying "Invalid Template".

Is the #= # syntax supported for row templates? Because I need this feature in a row template.

As further information: If I change #=<p>fieldName</p> # to #: fieldName # my template works properly.

 

Regards

Sebastian

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 29 Apr 2015, 06:38 AM
Hi Sebastian,

You should put the HTML tags outside the #= # expression:


<p>#= fieldName #</p>

The #= # expression must contain only valid JavaScript code.

Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Sebastian
Top achievements
Rank 1
answered on 29 Apr 2015, 11:19 AM

Hi,

the documentation says that there are three types of hash templates (http://docs.telerik.com/kendo-ui/framework/templates/overview). As I understand, the syntax for rendering JavaScript is the # # expression and to render HTML content it is the #= # expression.

But in row templates it seems to be not possible to render HTML content inside a hash template. My requirement says that it should be possible to pass HTML data (retrieved from the server) to a table and it has to display it correctly.

Regards,

Sebastian

0
Atanas Korchev
Telerik team
answered on 29 Apr 2015, 02:51 PM
Hi Sebastian,

The #= # syntax is what you must use in order to stop escaping HTML. However you can't put HTML tags inside the #= # expression itself.

Here is a live demo with the grid: http://dojo.telerik.com/@korchev/ikUCe

Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Sebastian
Top achievements
Rank 1
answered on 30 Apr 2015, 06:53 AM

Hi,

then I misunderstood the expression. But now it works fine.

Thank you very much.

Regards,

Sebastian

Tags
Grid
Asked by
Sebastian
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Sebastian
Top achievements
Rank 1
Share this question
or