更新时间:2023-02-05 15:08:11
The question is close to the other question which I answered recently. The distinguish is that you want to search for a selected column. For case-sensitive searching you can use following code
var index = 3;
var str = 'b';
$("#list > tbody > tr > td:nth-child("+index+"):contains('" + str + "')").parent();
对于不区分大小写的搜索,代码看起来像
For case-insensitive searching the code could look like
var index = 3;
var str = 'b';
var cells = $("#list > tbody > tr > td:nth-child(3)").filter(function() {
return re.test( $(this).text());
});
var rows = cells.parent();
重要的是要考虑到jqGrid有时在colModel
中声明的列之前还有其他列.这是"rn"列,其中包含行号.如果使用jqGrid的rownumbers: true
选项,则它存在.在使用选项multiselect: true
时,还有带有复选框的"cb"列.您可以根据$('#list').jqGrid('hideCol', 'cb');
隐藏该列,但是您也应该在那里进行计算.通常,您应该计算所有隐藏的列.
It is important to take in consideration that jqGrid has sometimes additional columns before the columns declared in the colModel
. This is 'rn' column contains row numbers. It exists if you use rownumbers: true
option of jqGrid. In you use the option multiselect: true
there are also 'cb' column with check-boxes. You can hide the column with respect of $('#list').jqGrid('hideCol', 'cb');
, but you should calculate there also. In general you should calculate all hidden columns.
您可以在以下小型演示中看到所有内容.
You can see all live in the following small demo.