Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqgrid get all grids column names

Is there a way to get all of the grid's column names?

like image 265
user590586 Avatar asked Mar 29 '11 16:03

user590586


1 Answers

You can get the column names with

var columnNames = $("#list")[0].p.colNames;

or

var columnNames = $("#list").jqGrid('getGridParam','colNames');

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.

like image 85
Oleg Avatar answered Nov 07 '22 16:11

Oleg