我想通过单击jqGrid中的按钮来添加新列

我想在jqGrid中点击按钮添加新列。 以下是我用来定义网格的代码。 有人可以帮助我,如何定位新的列位置。

jQuery("#list").jqGrid({ datatype: "local", height: 250, colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:60, sorttype:"int",editable:false,editoptions:{readonly:true,size:10}}, {name:'invdate',index:'invdate', width:90, sorttype:"date",editable:true,editoptions:{readonly:false,size:25}}, {name:'name',index:'name', width:100, editable:true,editoptions:{readonly:false,size:20}}, {name:'amount',index:'amount', width:80, align:"right",sorttype:"float", editable:true, editoptions:{readonly:false,size:20}}, {name:'tax',index:'tax', width:80, align:"right",sorttype:"float", editable:true,editoptions:{readonly:false,size:20}}, {name:'total',index:'total', width:80,align:"right",sorttype:"float", editable:true,editoptions:{readonly:false,size:20}}, {name:'note',index:'note', width:150, sortable:false, editable:true,editoptions:{readonly:false,size:20}} ], rowNum:10, rowList:[10,20,30], sortname: 'id', viewrecords: true, sortorder: "desc", editCaption: "Edit Record", caption: "Manipulating Grid Data", editurl:"someurl.php" }); 

它并不完全是你要求的,但我们通过在表格中包含我们希望它们出现的所有列来实现这一点,但在我们想要隐藏的那些列上有一个“hidden:true”属性。

然后,我们有一个“显示列”复选框列表,其中包含一些jQuery魔法来调用jqGrid showCol方法,以便在用户请求时显示这些列。