How to get jqGrid current search criteria?
15,296
Solution 1
Just to close this question I did this this the following line:
grid.getGridParam("postData").filters;
With this I get the filter expression the jqGrid generates when we're applying filters on its data.
Solution 2
$('#myGrid').getGridParam("postData").filters;
will give you a string (i don't know why string. why not JSON)
"{"groupOp":"AND","rules":[{"field":"Name","op":"bw","data":"a"}]}"
rules have the search criteria. If i have multiple search criteria, all would be there
"{"groupOp":"AND","rules":[{"field":"Name","op":"bw","data":"a"},{"field":"Description","op":"bw","data":"d"}]}"
Solution 3
var search = grid.getGridParam("postData").search;
...works for me.
Author by
AlexCode
Senior Consultant dealing with computers professionally since 2000. Experienced developer, architect and team leader feeling at ease around anything form the front-end to infrastructure. You can subscribe to my blog at: http://www.instanceofanobject.com
Updated on July 16, 2022Comments
-
AlexCode almost 2 years
I need to get the exact same thing the jqGrid passes on the GET/POST _search parameter.
How can I do this?
-
AlexCode almost 13 yearsThanks! My question body isn't quite correct, what I want isn't the _search which is a boolean but the filters that actually contains the json representation of the current filter applyed on the grid. So the way of getting is: grid.getGridParam("postData").filters;
-
Kevin Gauthier almost 13 yearsI don't understand what it is that you're asking for.
-
bkwdesign over 9 yearsThe new API mode will look like this: $('#myGrid').jqGrid('getGridParam', "postData").filters
-
low_rents about 8 yearsI also don't understand why it returns a string and not JSON.
-
Sergiy Ostrovsky over 6 yearsThis doesn't work for me when using
datatype: "json"
.