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

查看:16
本文介绍了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 选项要小心,因为上面所有的搜索构造搜索同样在'rn'列中包含行号.因此,如果您在输入字段中键入 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天全站免登陆