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

templates in widget

1 Answer 8 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 24 Nov 2012, 03:12 PM
let's say my dataSource returns an id such as {id: 1}

and i'm using a template

columns: [ {field: "id", template: "<a href='javascript:;' id='#= id #' />#= id #</a>"} ...


how would I get it to show up as <a href="javascript:;" id="1">#1</a> as ##=id # won't work

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 26 Nov 2012, 07:56 AM
Hello Phil,

The '#' symbol in  JavaScript is escaped with double backslash('\\'). All this is explained in the yellow box in the Templates Overview article. That said here is how the template should looks like:
"<a href='javascript:;' id='#= id #' />\\##= id #</a>"
 
//example
kendo.template( "<a href='javascript:;' id='#= id #' />\\##= id #</a>")({id: 1})
 
//will produce
"<a href='javascript:;' id='1' />#1</a>"


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
Phil
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or