jQgrid search a value on the grid
I have to search a value contained in a jQGrid and when found it, I have to delete the row.
How I can 开发者_开发知识库scan the rows of the grid?
Thanks.
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();
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.
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.
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.
精彩评论