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()");
var i = 0
<script>
function callback(){
#("th",tableid).each(function(){
if (++i == 9 || i == 10){
$(this).addclass("nodisplay");
}
}
}
</script>