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

HtmlAttributes on columns causes an "invalid template" error

3 Answers 631 Views
Grid
This is a migrated thread and some comments may be shown as answers.
gm
Top achievements
Rank 1
gm asked on 13 Jun 2013, 01:01 PM
I am migrating an application from release 2012.3.1114 to release 2013.1.319.  Previously, I was able to apply HtmlAttributes on columns in this manner:
@(Html.Kendo().Grid<ToolListItemView>().Name("texListGrid")
    .Columns(columns => {
        columns.Bound(m => m.ToolId);
        columns.Bound(m => m.Description).HtmlAttributes(new { style = "font-size: 1.3em;" });
        columns.Bound(m => m.LastModified);
        columns.Bound(m => m.ConditionName);
        columns.Bound(m => m.LocationName);
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("ToolsRead", "List").Data("listParams"))
    )
)
With release 2013.1.319, an "invalid template" error is generated from the above code.  If I change HtmlAttributes to HeaderHtmlAttributes, no errors are generated and the style is applied to the column header (i.e. the format of the HtmlAttributes isn't a problem).  I did verify that I could use HtmlAttibutes on a column with an @class parameter successfully, which is the correct way of applying styles.  I guess I'm wondering if this capability (local CSS styling via HtmlAttributes) was intentionally removed, or if I'm doing something wrong?

Note: Moved from Kendo UI Web forum.

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 13 Jun 2013, 02:55 PM
Hi Gregg,

I think I remember somebody else talking about a similar issue, but we did not manage to reproduce it. Please check whether changing the style value makes any difference, e.g. try removing the space between ":" and "1".

On a side note, using custom CSS classes and external styles is a lot better than applying inline styles to multiple elements.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
gm
Top achievements
Rank 1
answered on 13 Jun 2013, 04:48 PM
Hi Dimo,

Removing the spaces took care of the problem.  I agree that using classes is a better approach.  Actually, where I ran into problems was with a couple of columns where the content is acronyms.  I had been setting a title attribute so that when floating over the column a tool tip appeared with  what the acronyms meant (e.g. columns.Bound(m => m.ReleaseAcronym)..HtmlAttributes(new { title="R = Released, A = Archived" });  If I remove all the spaces it works.  I imagine there is a better way of displaying the information, but I went with the quick and dirty approach. :-)

It's not a big deal, I moved the title attribute to the header attributes, but there does seem to be a problem with any spaces in a html attribute value.  BTW, having spaces in the attribute value is not a problem when using HeaderHtmlAttributes.

Thanks, Gregg
0
Dimo
Telerik team
answered on 14 Jun 2013, 08:31 AM
Hello again,

We managed to track down the cause of the problem - it is the following declaration in the web.config:

<httpRuntime targetFramework="4.5" encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

It causes the spaces to be encoded, which leads to a parse error inside the internal Grid column template.

The issue is now fixed and changes will take effect in the next internal and official builds.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
gm
Top achievements
Rank 1
Answers by
Dimo
Telerik team
gm
Top achievements
Rank 1
Share this question
or