javascript 如何获取 jqGrid 当前搜索条件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6217499/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get jqGrid current search criteria?
提问by AlexCode
I need to get the exact same thing the jqGrid passes on the GET/POST _search parameter.
我需要得到 jqGrid 在 GET/POST _search 参数上传递的完全相同的东西。
How can I do this?
我怎样才能做到这一点?
回答by AlexCode
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.
有了这个,我得到了当我们对其数据应用过滤器时 jqGrid 生成的过滤器表达式。
回答by Jhankar Mahbub
$('#myGrid').getGridParam("postData").filters;
will give you a string (i don't know why string. why not JSON)
会给你一个字符串(我不知道为什么是字符串。为什么不是 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"}]}"
回答by Craig Stuntz
var search = grid.getGridParam("postData").search;
...works for me.
...对我有用。