//before document ready
var fieldEnabled = true;
// in document ready
isFieldEnabled(); // some method to check, that will update `fieldEnabled`
grid.jqGrid({
//Other attributes
colModel:[
{name: 'ID', 'index': 'ID', hidden: fieldEnabled ? false : true }
// field enabled is just a boolean that is updated by whatever method you need to check if the column needs to show
]
loadComplete : function(){
//no need for changes here
2条答案
按热度按时间rqenqsqc1#
试试这个. Sample fiddle
2nc8po8w2#
我想更新后,进入网格运行不自动调整大小,以隐藏列后的全宽。我发现向
colModel
的隐藏字段添加一个内联if语句能够解决这两个问题。第一个回答我就准备好被钉上十字架了。