Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webGrid.Column doesn't allow change in column width

I am using a webGrid and would like to be able to change the width of the columns. I am using the following code for the style but it seems to have no affect. webGrid.Column(columnName: "TRP_Comments", header: "Comments",style: "width:500px;"), Is this not what style is suppose to do? Thanks Bruce

like image 700
user1011441 Avatar asked Dec 13 '22 08:12

user1011441


1 Answers

The style property doesn't set the style attribute but the class attribute. Yeah, I know, WTF. The designers of the WebGrid component must have been mentally disturbed at the moment they choose the name of this optional argument. The whole dynamic and optional arguments stuff they put into this component makes me hate it like hell and never use it in any application.

Anyway, you could define a custom CSS class in your separate CSS file:

.comments {
    width: 500px;
}

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

webGrid.Column(columnName: "TRP_Comments", header: "Comments", style: "comments")
like image 132
Darin Dimitrov Avatar answered Dec 27 '22 07:12

Darin Dimitrov