jqgrid获取所有网格列名称 [英] jqgrid get all grids column names

查看:168
本文介绍了jqgrid获取所有网格列名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以获取网格的所有列名称?

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:truemultiselect:truesubGrid:true参数的情况下,数组columnNames最多包含三个空的第一元素.在colModel附加列中插入名称为'rn''cb''subgrid'的参数.因此,您可以忽略columnNames的第一个空元素,也可以在colModel($("#list")[0].p.colModel$("#list").jqGrid('getGridParam','colModel'))中另外查找. colModelcolNames数组具有相同的长度,并且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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆