jqGrid add new column(jqGrid 添加新列)
问题描述
我发现在 JQuery 的 jqGrid 插件中我可以动态添加行,但是我可以对列做同样的事情吗?如果有一个简单的表格,我更愿意手动手动完成,但是 jqGrid 将表格信息存储在很多 div 中.
I found that in jqGrid plugin for JQuery I can add rows dynamically, but can I do the same with columns? If there would be a simple table I'd prefer to do this manually by hands, but jqGrid stores table information in a lot of divs.
推荐答案
无法动态添加列到jqGrid.您必须使用 colModel
重新创建整个网格,其中包含一列.如果你使用单独的 colNames
,那么数组的大小也必须增加.例如,您可以使用 GridDestroy 来销毁现有网格.也可以使用 jQuery.Remove
或 jQuery.Empty
代替.
It is not possible to add a column to the jqGrid dynamically. You have to recreate the whole grid with colModel
having one column more. If you use separate colNames
, then the size of the array have to be increased too. You can use GridDestroy for example to destroy the existing grid. The usage of jQuery.Remove
or jQuery.Empty
instead is also possible.
更新:在我看来,GridUnload 更适合您的建议.我创建了 小型演示,它演示了如何重新创建网格.为了能够使用 GridUnload 或 GridDestroy 你必须确认你在你的项目(如果您使用 jqGrid 的开发人员版本)或者您已在 jqGrid 下载 页面.
UPDATED: It seems to me that GridUnload is better for your porpose. I created small demo which demonstrate how one can recreate a grid. To be able to use GridUnload or GridDestroy you have to verify that you include grid.custom.js in your project (if you use developer version of the jqGrid) or you have checked "Custom" "Additinal methods" on the jqGrid download page.
UPDATED 2:可以使用 addColumn
方法,该方法可以从 这里(参见 jQuery.jqGrid.addColumn.js
).该方法仍处于测试阶段.您可以在 here 找到一些演示如何使用该方法(参见addColumnX.htm
示例).
UPDATED 2: One can use addColumn
method which can be downloaded from here (see jQuery.jqGrid.addColumn.js
). The method is still in beta phase. One can find some demos which shows how to use the method here (see addColumnX.htm
examples).
这篇关于jqGrid 添加新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jqGrid 添加新列


基础教程推荐
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01