【问题标题】:I want to add new columns by clicking a button in jqGrid我想通过单击 jqGrid 中的按钮来添加新列
【发布时间】:2010-03-06 13:34:52
【问题描述】:

我想在 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"
 }); 

【问题讨论】:

    标签: jquery jqgrid


    【解决方案1】:

    这并不完全符合您的要求,但我们通过在表格中包含我们希望它们出现的所有列来实现这一点,但在我们最初想要隐藏的列上使用“hidden:true”属性.

    然后,我们有一个“显示列”复选框列表,带有一点 jQuery 魔法,可以调用 jqGrid 的 showCol 方法在用户请求时显示这些列。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-14
      • 2015-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-23
      相关资源
      最近更新 更多