将Bootstrap类添加到asp.net mvc webGrid列

时间:2015-03-05 16:21:28

标签: asp.net-mvc twitter-bootstrap asp.net-mvc-4 razor webgrid

我的asp.net mvc web应用程序中有以下WebGrid列: -

gridcolumns.Add(new WebGridColumn() { ColumnName ="Description",Header = Html.DisplayNameFor(model => model.Content.FirstOrDefault().Description).ToString(),CanSort=true
,
    Format = @<text>@item.TrimmedDescription</text>});

我的问题是我如何将hidden-sm bootstrap类添加到上面的列中,以便该列隐藏在小型设备上?有人可以建议吗?

由于

修改

我将Style定义如下: -

gridcolumns.Add(new WebGridColumn() { ColumnName ="Description",Header = Html.DisplayNameFor(model => model.Content.FirstOrDefault().Description).ToString(),CanSort=true
,
    Format = @<text>@item.TrimmedDescription</text>,Style="hidden-sm"});
var grid = new WebGrid(
                        canPage: true,
                        rowsPerPage: Model.PageSize,
                        canSort: true,
                        ajaxUpdateContainerId: "skillgrid", fieldNamePrefix: "skill");

            grid.Bind(Model.Content, rowCount: Model.TotalRecords, autoSortAndPage: false);
            grid.Pager(WebGridPagerModes.All);

            @grid.GetHtml(htmlAttributes: new { id = "skillgrid" },   // id for ajaxUpdateContainerId parameter
            fillEmptyRows: false,
            tableStyle: "table table-bordered table-hover",
            mode: WebGridPagerModes.All,
            columns: gridcolumns

            );

上面已删除了小型设备上的Description列,但网格标题仍显示“描述”。所以现在我在WebGrid标题和WebGrid列内容之间出现错误重叠...

1 个答案:

答案 0 :(得分:1)

它具有style属性,您只需设置WebGridColumn属性的属性:

style: "yourcssclass"

或:

style = "yourcssclass"

您还可以查看this article

相关问题