如何隐藏Web网格中的特定列

时间:2014-01-08 06:05:14

标签: asp.net-mvc-4 razor

<div id="gridContent">
@grid.GetHtml(tableStyle:"webGrid",
headerStyle: "header",
alternatingRowStyle:"alt",
selectedRowStyle:"select",
columns:grid.Columns(grid.Column("Name","Name",style:"description"),grid.Column("DomainName","Domain Name",style:"hide"),grid.Column("ClientID","client ID",,style:"hide")</div>
<style type="text/css">
.hide {display:none;}<style>

我正在尝试使用上面的代码隐藏列,但是列标题没有隐藏。如何隐藏列标题?

2 个答案:

答案 0 :(得分:1)

你可以拥有类似的东西

@{

  var grid = new WebGrid(Model);

    @grid.GetHtml(columns: grid.Columns(grid.Column(null,null, format: @<input type="hidden" name="IDHidden" value="@item.IDHidden"/>),

                                                             grid.Column("Title", "Title")));

}

答案 1 :(得分:1)

太容易了,只需评论此部分。 就像那样

    @*grid.Column( "null" ,format:@<input type="hidden" name="ID" id="ID"/>),*@

    grid.Column("Description",canSort:true,header: "Description",format: @<span>
        <span id="spanDescription_@item.ID">@item.Description</span> 
        @Html.TextBox("Description"+(int)item.ID,(string)item.Description,new{@style="display:none"})</span>),