【问题标题】:Add Bootstrap class to an asp.net mvc webGrid column将 Bootstrap 类添加到 asp.net mvc webGrid 列
【发布时间】:2015-03-05 16:21:27
【问题描述】:

我的 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 引导类添加到上面的列中,以便在小型设备上隐藏该列?谁能给点建议?

谢谢

编辑

我将样式定义如下:-

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

            );

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

【问题讨论】:

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


    【解决方案1】:

    它有一个style 属性,你只需设置WebGridColumn 属性的那个属性:

    style: "yourcssclass"
    

    或:

    style = "yourcssclass"
    

    您也可以查看this article

    【讨论】:

    • 所以我可以在 style 中添加一个 css 类,例如 style: "hidden-sm" ???
    • 这已经删除了小型设备上的列内容,但列标题仍然显示,请您检查我在原始问题中的编辑吗?
    • 您还必须在标题上添加类
    • WebGrid 是否支持为 header 定义样式?
    • 我不知道@john G 对此感到抱歉
    猜你喜欢
    • 1970-01-01
    • 2013-01-07
    • 1970-01-01
    • 1970-01-01
    • 2011-12-02
    • 2018-04-01
    • 2011-06-22
    • 2012-01-19
    • 2018-07-19
    相关资源
    最近更新 更多