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

[Solved] Template in Autogenerated Columns

1 Answer 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kuangyi
Top achievements
Rank 1
Kuangyi asked on 10 Nov 2011, 11:51 PM
Hi, I wish for one of my autogenerated columns to have a custom look, however I don't know how to set the template for it.

I tried :
columns.AutoGenerate(column =>
{
if(column.Member == "ColToTemplate")
{
column.template(@<img ..... />);
}
}

But it fails as "column" is not the same class as columns.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 11 Nov 2011, 10:18 AM
Hello Kuangyi,

The correct syntax is:

WebForms: (server binding, server template)

if (column.Member == "Address")
{
    column.Template = p => { %> <%=p.Address%> <% };
}

Razor: (server binding, server template)

if (column.Member == "Address")
{
     column.InlineTemplate = @<text>@item.Address</text>;
}


Client Templates, client binding, both view engines:

if (column.Member == "Address")
{
    column.ClientTemplate = "aaaa";
}


Greetings,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
Kuangyi
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or