So I have a grid with a ClientDetailTemplate, with both having client templates referring to item values. This works fine, basically something like
@(Html.Kendo().Grid(Model.Fields) .Name("FieldsGrid") .Columns(columns => { columns.Bound(o => o.Title).Title("Title").Width("25%") .HeaderHtmlAttributes(new { Title = "Title", style = "text-align:center;" }) .HtmlAttributes(new { Class = "lt" }).ClientTemplate( "<a target='_blank' href='#= Url #'>#= Title #</a>" ); }) .ClientDetailTemplateId("template") )<script id="template" type="text/kendo-tmpl"> @(Html.Kendo().Grid(Model.JobSearchResults) .Name("CareerJobSearchResultGrid_#=JobSearchId#") .Columns(columns => { columns.Bound(o => o.Title).Title("Title").Width("40%") .HeaderHtmlAttributes(new { Title = "Title", style = "text-align:center;" }) .HtmlAttributes(new { Class = "lt" }).ClientTemplate( "<a target='_blank' href='\\#= Url \\#'>\\#= Title \\#</a>" ); }) .ToClientTemplate() )</script>
The problem is when I want to add some HTML attributes based on some model information, trying to do something like
.HtmlAttributes(new { Class = "lt", data_title = "#= Title #" })I can't get this to work for either the grid or its client template, regardless of escapes etc.
Basically, it doesn't appear to do the substitutions, and in both cases, I get an error:
SyntaxError: missing : after property id ...tes:{Class:"lt",data-title:"#= Title #"},width:"10%",tem
Is what I'm trying to do possible and I'm just using the wrong syntax? Or is it not possible?
Thanks in advance.
