This question is locked. New answers and comments are not allowed.
Can I add a class name to the td tag in the grid? right now the grid contains the table with just <td> and I want to be able to format the td with the css class. How could I add to my code so the td can be <td class="css" title="title">?
My current code looks like this:
My current code looks like this:
columns.Bound(o => o.Description).Width(150)
.HeaderHtmlAttributes(center)
6 Answers, 1 is accepted
0

Sang
Top achievements
Rank 1
answered on 07 Sep 2012, 01:47 PM
I found part of the answer but now I cannot add the column values to the title.
columns.Bound(o => o.Description).Width(150)
.HeaderHtmlAttributes(center)
.HtmlAttributes(new { title ="description" , @class = "rite-grid-desc" });
How do I put o.Description to the title? I've tried using <#Description#> but it does not work. TIA.
columns.Bound(o => o.Description).Width(150)
.HeaderHtmlAttributes(center)
.HtmlAttributes(new { title ="description" , @class = "rite-grid-desc" });
0

Pedro
Top achievements
Rank 2
answered on 07 Sep 2012, 07:05 PM
have you tried <#= Description #> ? (with the equal sign)
0

Sang
Top achievements
Rank 1
answered on 07 Sep 2012, 07:10 PM
I did, sorry, it was a mis-typed.
columns.Bound(o => o.Description).Width(150)
.HeaderHtmlAttributes(center)
.HtmlAttributes(new { title = "<#=Description#>", @class = "rite-grid-desc" });
The column just display exactly what I have there, it did not evaluate the value.
columns.Bound(o => o.Description).Width(150)
.HeaderHtmlAttributes(center)
.HtmlAttributes(new { title = "<#=Description#>", @class = "rite-grid-desc" });
0

Pedro
Top achievements
Rank 2
answered on 07 Sep 2012, 07:40 PM
Hello,
Sorry but i couldn't find an easier way to do it.
But here you go:
try putting that into your grid.
Sorry but i couldn't find an easier way to do it.
But here you go:
.Name("Grid")
.CellAction(cell =>
{
if (cell.Column.Member == "Description")
{
cell.HtmlAttributes["title"] = cell.DataItem.Description;
}
})
try putting that into your grid.
0

Sang
Top achievements
Rank 1
answered on 10 Sep 2012, 03:16 PM
I found another way to accomplish this. What I did was using the clientTemplate, it works well.
Hopefully this will help others.
.ClientTemplate("<
span
class
=
'rite-grid-desc'
title='<#= TestCodeDescription #>'><#= TestCodeDescription #></
span
>");
Hopefully this will help others.
0

Pedro
Top achievements
Rank 2
answered on 10 Sep 2012, 05:54 PM
I had found that way too, but the difference between that one and the method i gave you is
The Client Template gives you the html schema of:
The Cell Actions gives you this:
If you're happy with your way, great. If you need the class and title to be on the <td> element then Cell Action is way.
Pedro
The Client Template gives you the html schema of:
<
td
>
<
span
class
=
"someClass"
title
=
"someTitle"
>
Text
</
span
>
</
td
>
The Cell Actions gives you this:
<
td
class
=
"someClass"
title
=
"someTitle"
>
Text
</
td
>
If you're happy with your way, great. If you need the class and title to be on the <td> element then Cell Action is way.
Pedro