I need to customize the width and alignment of each column in a WEBGRID within MVC 3. Specifically, I have 5 columns and I want to set different width and alignment for each header.
Here is my code snippet:
@{WebGrid grid = new WebGrid();
if (@Model.VendorItemsList != null)
{
grid = new WebGrid(source: @Model.VendorItemsList, ajaxUpdateContainerId: "gridSearch", canSort: true, rowsPerPage: Model.PageSize);
}
}
<div id="gridSearch" class="tableGrid">
@{
@grid.GetHtml(
mode: WebGridPagerModes.All,
columns: grid.Columns(
grid.Column("VendorItemName", header: @GeneralResource.Vendor + " " + @GeneralResource.Item + " " + @GeneralResource.Name),
grid.Column("ItemName", header: @GeneralResource.Item),
grid.Column("ItemCategoryName", header: @GeneralResource.Category),
grid.Column("VendorName", header: @GeneralResource.Vendor)
))
}
}
</div>