Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the jqGrid colModel

Tags:

jquery

jqgrid

How can I get the entire colModel for a jqGrid element? I've gone through the source code a bit and also played around with some tests, but nothing seems to return the actual array.

Thanks.

like image 299
Dave Avatar asked May 27 '10 01:05

Dave


People also ask

What is colModel in jqGrid?

In a nutshell, colNames defines the names of your jqGrid columns on the page, and colModel specifies options for each column (name in the dataset, width, etc). The documentation has more information: colModel Array which describes the parameters of the columns. This is the most important part of the grid.

How do I get the value of a column in jqGrid?

var myGrid = $('#list'); var rowID = myGrid. jqGrid ('getGridParam', 'selrow'); var cellVal = myGrid. jqGrid ('getCell', rowID, 'colName'); Where colName is the name of column for which you want to find value for that, which you gave to your column in the colModel.

How do I enable search option in jqGrid?

jqGrid support search toolbar mode, where you can have search toolbar on top of each column of the grid. To use, call the filterToolbar method. You can exclude certain columns from appearing in the search options by setting the search property of the respective column to false.

How do you use jqGrid?

In this step, we are going to add jqGrid Script and CSS reference to index view. This script is added to project when we add jqGrid Grid from NuGet package. After adding Scripts and Css next we need to add table element for reserve the place where the grid should be created.


2 Answers

You can use getGridParam - just pass the colModel option:

jQuery("#mygrid").jqGrid ('getGridParam', 'colModel');

You can look at the jqGrid docs for getGridParam for more information...

like image 99
Justin Ethier Avatar answered Oct 24 '22 23:10

Justin Ethier


So I did figure it out. In the custom navigation button (onClickButton function), I just used :

this.p.colModel
like image 37
Dave Avatar answered Oct 24 '22 23:10

Dave