简体   繁体   English

如何通过某些列值获取jqgrid行索引?

[英]How to get jqgrid row index by some column value?

I want to get jqgrid row id by some column value. 我想通过某些列值获取jqgrid行ID。

Example: i have one column called 'example_id' and i need jqgrid row id given that random 'example_id'. 示例:我有一列名为“ example_id”,鉴于随机的“ example_id”,我需要jqgrid行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. 我想您以不完全正确的方式填充jqGrid数据。 You wrote about "row index" instead of rowid. 您写的是“行索引”而不是rowid。 So I suppose that you don't specified id or rows in your input data. 因此,我想您没有在输入数据中指定id或行。 jqGrid need always assign unique value of id attribute of every row of grid (the id of <tr> elements). jqGrid 始终需要为网格的每一行分配唯一的id属性值( <tr>元素的id )。 Because of "must to have" character of the information jqGrid have to assign some values like 1, 2, 3 as rowids. 由于信息的“必须具有”字符,jqGrid必须将一些值(例如1、2、3)分配为rowid。 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 . 如果您的网格具有包含本机唯一信息的example_id列,我建议您在colModel的列定义中使用key: true属性。 In the case jqGrid will use the value from the column to assign id attribute of rows of the grid. 在这种情况下,jqGrid将使用列中的值来分配网格行的id属性。 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. 或者,您可以使用getCol方法获取诸如{id:rowid, value:cellvalue}类的项目数组,其中value属性包含example_id列中的值,而id包含相应的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. 使用$ .map方法,您可以轻松分析数组并获取在example_id列中包含某些特定值的行的ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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