It's easy enough to add a class to a td in a webgrid, for example:
new WebGridColumn {
ColumnName= "Owl.Species",
Header= "Scientific Name",
Style= "sci-name"
}
The style tag adds the class "sci-name" to the td
. How can I add a class to the th
for that column without using jQuery which wouldn't be the ideal solution.
I don't think there's a built-in way to do it. You can't even extend the WebGrid classes, as their methods aren't marked virtual. The best way I can think of is to use some CSS, nth-child
to target the th
element by its index.
<style type='text/css'>
table thead tr th:nth-child(2) {
background: yellow;
}
</style>
Still not ideal, but I think better than using JQuery.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With