Search code examples
teleriktelerik-gridtelerik-mvc

Assign column name as class name telerik grid mvc


i have a telerik grid in my view and i want to assign the column name as the class attribute

 .Columns(columns =>
        {

            columns.Bound(o => o.xyz).Width(70).Groupable(false).Title("Reply Status").HtmlAttributes(new { @class=xyz});      
                            ------^                                                                    -------------^                                         
        })

is that possible.


Solution

  • First of all make sure you are strongly binding the view with the model

    Next you can try

    .Columns(columns =>
          {    
            columns.Bound(o => o.xyz).Width(70).Groupable(false).Title("Reply Status")
                                            .HtmlAttributes(new { @class="<#=xyx#>"});                                    
            columns.Template(t => { }).ClientTemplate(                    
                    "<span class='<#=xyx#>'>some randon text</span>"                    
                    );
        })