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

Bug while setting CSS in template

3 Answers 187 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 21 Mar 2012, 02:57 PM
The KendoGrid does not seem to handle some CSS settings within a template.

   $("#myList").kendoGrid({
dataSource: mySource
columns: [
{ field:
"SupplierName", title: "Vendor Name:" },
{ field:
"ColorCode", title: "Vendor Status", template: '<div style="width: 50px; height:20px; background-color: #FF16DC04">#= ColorCode #</div>'}]
});

The # is causing problems even when not grouped together with the equal sign (=).

3 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 21 Mar 2012, 03:27 PM
Hello,

You have to escape the # character using two backslashes. 

Regards,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jason
Top achievements
Rank 1
answered on 21 Mar 2012, 09:32 PM
That solved the issue by having the color code "hardcoded"

 background-color: \\#00ff00;">#= ColorCode #</div>'} 

But when I try to set it with the actual color code from my datasource, I run into the same problem.
The ColorCode property holds the value "#f00ff00". 

 background-color: \\\\#= ColorCode #;">#= ColorCode #</div>'} 

How may I make it "ignore" the # from the property?
0
Deb
Top achievements
Rank 1
answered on 03 Apr 2012, 10:04 PM
$("#myList").kendoGrid({
dataSource: mySource
columns: [
{ field:
"SupplierName", title: "Vendor Name:" },
{ field:
"ColorCode", title: "Vendor Status", template: '<div style="width: 50px; height:20px; background-color: #FF16DC04">#= ColorCode #<//div>'}]

// escape ?
Tags
Templates
Asked by
Jason
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Jason
Top achievements
Rank 1
Deb
Top achievements
Rank 1
Share this question
or