我想通过单击jqGrid中的按钮来添加新列 [英] I want to add new columns by clicking a button in jqGrid
问题描述
我要在jqGrid中单击的按钮上添加新列.以下是我用来定义网格的代码.有人可以帮助我,如何定义具有位置的新列.
I want to add new column on a button click in jqGrid. Following is the code that i am using to define a grid. can someone help me, how to define new columns with position.
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"属性.
It's not exactly what you're asking for, but we achieve this by including all the columns in the table where we want them to appear, but with a "hidden:true" property on the ones we want to be hidden initially.
然后,我们在复选框的显示列"列表中添加了一些jQuery魔术,以调用jqGrid showCol方法在用户要求时显示这些列.
We then have a "Show Columns" list of checkboxes with a bit of jQuery magic to call the jqGrid showCol method to show those columns when the user asks for them.
这篇关于我想通过单击jqGrid中的按钮来添加新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!