2

我正在使用 WebGrid 显示动态选择的表列我想隐藏未选择的列。如何动态隐藏列标题?

我正在使用关注 webgrid。

    <div>   
    @{    
    var grid = new WebGrid(Model.oTravelReadyEntities);
    grid.Pager(WebGridPagerModes.NextPrevious);
    @grid.GetHtml(tableStyle: "WebGrid",
    headerStyle: "Header",
    alternatingRowStyle: "alt",
    columns: grid.Columns(


    grid.Column("Var_AssoId", "Var_AssoId", canSort: true, format: @<text>            
    @if(item.Var_AssoId == 0){@Html.Hidden("Var_AssoId", "Var_AssoId");        
    }                                                                                               
    else{ @item.Var_AssoId}</text>),

    grid.Column("Var_AssociateName", "Var_AssociateName", format: @<text>
    @if (item.Var_AssociateName == null)
    {@Html.Hidden("Var_AssociateName", "Var_AssociateName")}
    else
    {@item.Var_AssociateName}</text>),


    grid.Column("Var_Grade", "Var_Grade", format: @<text>
    @if (item.Var_Grade == null)
    {@Html.Hidden("Var_Grade", "Var_Grade")}
    else
    {@item.Var_Grade}</text>),

    grid.Column("Char_VirtualPool", "Char_VirtualPool", format: @<text>
    @if (item.Char_VirtualPool == null)
    {@Html.Hidden("Char_VirtualPool", "Char_VirtualPool")}
    else
    {@item.Char_VirtualPool}</text>),

    grid.Column("Var_VirtualPoolCatagory", "Var_VirtualPoolCatagory", format: @<text>
    @if (item.Var_VirtualPoolCatagory == null)
    {@Html.Hidden("Var_VirtualPoolCatagory", "Var_VirtualPoolCatagory")}
    else
    {@item.Var_VirtualPoolCatagory}</text>),

    grid.Column("Char_VisaUtilization", "Char_VisaUtilization", format: @<text>
    @if (item.Char_VisaUtilization == null)
    {@Html.Hidden("Char_VisaUtilization", "Char_VisaUtilization")}
    else{@item.Char_VisaUtilization}</text>),

    grid.Column("Var_Deparment", "Var_Deparment", format: @<text>
    @if (item.Var_Deparment == null){@Html.Hidden("Var_Deparment", "Var_Deparment")}
    else{@item.Var_Deparment}</text>),

    grid.Column("Var_Vertical", "Var_Vertical", format: @<text>
     @if (item.Var_Vertical == null){@Html.Hidden("Var_Vertical", "Var_Vertical")}
    else{@item.Var_Vertical}</text>),

    grid.Column("Var_AccountName", "Var_AccountName", format: 
    @<text>@if (item.Var_AccountName == null){
    @Html.Hidden  ("Var_AccountName", "Var_AccountName")}
    else{@item.Var_AccountName}</text>),

    </div>

我想在某些条件下隐藏列标题。如何使用条件语句隐藏列标题?

4

1 回答 1

0

这是有条件地显示/隐藏我发现有用的 webgrid 列的一种方法:MVC 3 Webgrid - 如何隐藏不想显示的列?

于 2013-11-09T02:22:09.057 回答