简体   繁体   中英

How to get jqgrid row index by some column value?

I want to get jqgrid row id by some column value.

Example: i have one column called 'example_id' and i need jqgrid row id given that random 'example_id'. Is that possible?

note: i don't click on the table, it's a parameter passed by url

I suppose that you fill jqGrid data in not full correct way. You wrote about "row index" instead of rowid. So I suppose that you don't specified id or rows in your input data. jqGrid need always assign unique value of id attribute of every row of grid (the id of <tr> elements). Because of "must to have" character of the information jqGrid have to assign some values like 1, 2, 3 as rowids. If your grid have column example_id with native unique information I would recommend you to use key: true property in the definition of the column in colModel . In the case jqGrid will use the value from the column to assign id attribute of rows of the grid. So you can solve your problem in the way.

Alternatively you can use getCol method to get array of items like {id:rowid, value:cellvalue} where value property contain the value from example_id column and id contains the corresponding rowid. In the way you will . Using $.map method you can easy analyse the array and get the ids of rows which contains some specific value in example_id column.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM