非淡泊无以明志,非宁静无以致远 -心静如止水,动于静

MVC中webGrid想加一列隐藏控件

方法一:利用CSS将column设成隐藏

<style type="text/css">
   
.nodisplay {display: none;}
</style>

footerStyle :"table-footer",
...
grid
.Column(null,null, style:"nodisplay",...

 

方法二:用input type=hidden

@{

  var grid =newWebGrid(Model);

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

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

}

 

以上两种并不能将表的header隐藏掉,还秘须用javascript将table中的th也进行隐藏还是完美。如:

var grid =newWebGrid(data, ajaxUpdateContainerId :"grid", 
                ajaxUpdateCallback:"callBack()");
<script>
function callback(){
var i  = 0

   #("th",tableid).each(function(){

      if (++i == 9 || i == 10){

           $(this).addclass("nodisplay");
}

}

}
</script>
posted @ 2013-06-19 21:43  烟雨客  阅读(1383)  评论(0编辑  收藏  举报