4

I am trying to set width for Webgrid column. But it is not working. Anyone help me please.

Please find below my code

@grid.GetHtml(
tableStyle: "webgrid-table",
headerStyle: "webgrid-header",
alternatingRowStyle: "webgrid-alternating-row",
mode: WebGridPagerModes.All,
columns:grid.Columns(
grid.Column(columnName:"ID", header: "ID",canSort:true, style: "id"),
grid.Column(columnName:"Name", header: "Name",canSort:true,style: "name")
)

And my css file

.webgrid-table { border: 1px solid #98BF21;   }
.webgrid-header { background-color: #A7C942; color: #FFFFFF; text-align: left;}
.webgrid-alternating-row { background-color: #EAF2D3; }
.id { width: 20px; }
.name { width: 40px; }

Anyone help me please?

Thiru
  • 43
  • 1
  • 5

1 Answers1

3

You need to specify the width of the WebGrid itself in order to solve this issue.

Add this

.webgrid-table { *width*: *specify the width value here* ;border: 1px solid #98BF21;}
VVN
  • 1,607
  • 2
  • 16
  • 25
user2217303
  • 356
  • 4
  • 16