10

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

How can I do this?

pixelbobby
  • 4,368
  • 5
  • 29
  • 49
AlexCode
  • 4,055
  • 4
  • 33
  • 46

3 Answers3

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.

AlexCode
  • 4,055
  • 4
  • 33
  • 46
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"}]}" 
Jhankar Mahbub
  • 9,746
  • 10
  • 49
  • 52
2
var search = grid.getGridParam("postData").search;

...works for me.

Craig Stuntz
  • 125,891
  • 12
  • 252
  • 273
  • 1
    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; – AlexCode Jun 03 '11 at 10:29
  • I don't understand what it is that you're asking for. – Craig Stuntz Jun 03 '11 at 12:40