How to get jqGrid current search criteria?
Asked Answered
C

3

10

I need to get the exact same thing the jqGrid passes on the GET/POST _search parameter.

How can I do this?

Clubman answered 2/6, 2011 at 16:43 Comment(0)
C
13

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.

Clubman answered 3/7, 2011 at 17:13 Comment(1)
This doesn't work for me when using datatype: "json".Villose
S
5
$('#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"}]}" 
Spiderwort answered 8/4, 2013 at 17:4 Comment(2)
The new API mode will look like this: $('#myGrid').jqGrid('getGridParam', "postData").filtersCoeval
I also don't understand why it returns a string and not JSON.Secrest
C
2
var search = grid.getGridParam("postData").search;

...works for me.

Catima answered 2/6, 2011 at 16:52 Comment(2)
Thanks! 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;Clubman
I don't understand what it is that you're asking for.Catima

© 2022 - 2024 — McMap. All rights reserved.