jQgrid在网格上搜索值 [英] jQgrid search a value on the grid

查看:73
本文介绍了jQgrid在网格上搜索值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须搜索jQGrid中包含的值,当找到它时,我必须删除该行.

I have to search a value contained in a jQGrid and when found it, I have to delete the row.

如何扫描网格的行?

谢谢.

推荐答案

我如何理解您的问题,您正在使用本地网格并希望在jqGrid的当前页面上搜索文本.在这种情况下,您可以使用jQuery.像

How I understand your question you work with local grids and want to search for text on the current page of jqGrid. In the case you can use jQuery. The construct like

$("#list > tbody > tr td:contains('" + str + "')").parent();

可用于查找所有包含字符串str的行(区分大小写).要删除该行,您可以使用 delRowData 方法.要使用jQuery进行不区分大小写的搜索,可以使用不同的方法.最简单的一种方法是使用RegEx. 此处.

can be used to find all rows contain string str (case sensitive). To delete the row you can use delRowData method. To make case insensitive search with jQuery there are different methods. One on the simplest is to use RegEx. Another method is described here.

您可以在此处看到一个小型演示,它演示了两种情况敏感和不区分大小写的数据搜索.

You can see a small demo here which demonstrate both case sensitive and case insensitive data seraching.

已更新:除了使用parent()方法之外,还可以使用:has过滤器:

Updated: Instead of the usage of parent() method one can also use :has filter:

$("#list > tbody > tr:has(td:contains('" + str + "'))");

另一个答案,对您的问题可能也很有趣.

Another answer on the close question could be also interesting for you.

备注:如果您使用rownumbers: true选项,请小心,因为所有上述搜索结构都在列中搜索并包含行号.因此,如果您在输入字段中输入3,则第三行将被删除.

Remark: Be careful if you use rownumbers: true option because all above search constructs search also in column 'rn' contains row numbers. So if you type 3 in the input field the third row will be deleted.

这篇关于jQgrid在网格上搜索值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆