jqgrid获取所有网格列名称 [英] jqgrid get all grids column names
问题描述
是否可以获取网格的所有列名称?
Is there a way to get all of the grid's column names?
推荐答案
您可以使用
var columnNames = $("#list")[0].p.colNames;
或
var columnNames = $("#list").jqGrid('getGridParam','colNames');
唯一的小问题是,在使用rownumbers:true
,multiselect:true
或subGrid:true
参数的情况下,数组columnNames
最多包含三个空的第一元素.在colModel
附加列中插入名称为'rn'
,'cb'
或'subgrid'
的参数.因此,您可以忽略columnNames
的第一个空元素,也可以在colModel
($("#list")[0].p.colModel
或$("#list").jqGrid('getGridParam','colModel')
)中另外查找. colModel
和colNames
数组具有相同的长度,并且colModel[i].name
可用于检查colNames[i]
是"real"列的名称还是由于上面提到的树的用法而添加的附加列参数.
The only small problem is that the array columnNames
will contain up to three empty first elements in case of you use rownumbers:true
, multiselect:true
or subGrid:true
parameters. This parameters to follow to inserting in the colModel
additional columns with the names 'rn'
, 'cb'
or 'subgrid'
. So you can either just ignore the first empty elements of columnNames
or look additionally in the colModel
($("#list")[0].p.colModel
or $("#list").jqGrid('getGridParam','colModel')
). The colModel
and colNames
arrays has the same length and the colModel[i].name
can be used to examine whether colNames[i]
is the name of "real" column or an additional column added because of the usage one from the tree above mention parameters.
这篇关于jqgrid获取所有网格列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!