Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get select's value in jqGrid when using <select> editoptions on a column

Tags:

select

jqgrid

I have a couple of columns in jqGrid with edittype="select". How can I read the option value of the value currently selected in a particular row?

e.g.: When I provide the following option, how do I get "FE" for FedEx, etc.

editoption: { value: “FE:FedEx; IN:InTime; TN:TNT” } 

getRowData() for the rowId/cellname returns only the text/displayed component of the select.

If I set a "change" data event on the column, the underlying fires change events only on mouse clicks, and not keyboard selects (there's numerous references to generic selects and mouse/keyboard issues).

Bottomline, when a new value is selected, I need to know the option value at the time of the change, and also prior to posting to the server.

like image 701
Venkat Peri Avatar asked Apr 05 '10 21:04

Venkat Peri


People also ask

How do I get the value of a jqGrid cell?

How to get a cell value in JQGrid? var ret = jQuery("#MyGrid"). jqGrid('getRowData', id); ret = ret.

How do I select rows in jqGrid?

jQuery grid with row selections. Rows can be selected in ParamQuery Grid either by user action or programmatically. All rows can be selected using Ctrl - A or Cmd - A (Mac).

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.


1 Answers

You have to set the formatter of the column to 'select'

Example from the wiki:

colModel : [ {name:'myname', edittype:'select', formatter:'select', editoptions:{value:"1:One;2:Two"}} ... ]

See more here jqgridwiki

I was having the same problem and this worked like a charm

like image 56
Mariano Quevedo Avatar answered Sep 29 '22 19:09

Mariano Quevedo