WebGrid.Column does not allow changing column width

I am using webGrid and want to be able to change the width of the columns. I use the following code for the style, but it doesn't seem to be affected. webGrid.Column (columnName: "TRP_Comments", heading: "Comments", style: "width: 500px;") Isn't that what the style should do? thanks bruce

+4
source share
1 answer

The style property does not set the style attribute, but the class attribute. Yes, I know WTF. WebGrid component designers should have been mentally disturbed the moment they choose the name of this optional argument. All the dynamic and optional arguments that they insert into this component make me hate it like hell and never use it in any application.

In any case, you can define a custom CSS class in a separate CSS file:

 .comments { width: 500px; } 

and then assign the corresponding <td> elements to this class:

 webGrid.Column(columnName: "TRP_Comments", header: "Comments", style: "comments") 
+13
source

Source: https://habr.com/ru/post/1381166/


All Articles