我正在提供我自己提出的问题的答案。
有两种方式来捕获滤波器参数
如果您设置stringResult选项,真正在
jQuery("#grid_id").jqGrid('filterToolbar', {stringResult: true});
滤波器参数得到提交为具有以下格式的JSON字符串
{"groupOp":"AND", // the group operation when you have multiple feilds to search on
"rules":[
{"field":"countrycode", // the field/columns being searched on
"op":"bw", // operator for searching, here bw mean beginning with
"data":"ind”}] // the search string for the above field
}
然后我们可以决定如何处理来自上述JSON字符串的过滤器参数。推荐的方法是使用可用的JSON库,可以将Java对象转换为JSON字符串,反之亦然。
在这种情况下,方法签名来处理,这将是为
@RequestMapping(value= "/cityData", method = RequestMethod.POST)
public @ResponseBody PageResponse getCityList(@RequestParam("page") int pageNo,
@RequestParam("rows") int rowLimit,
@RequestParam("sidx") String sortCol,
@RequestParam("sord") String sortDir,
@RequestParam("_search") boolean search,
//captures the filter parameters as a json string
@RequestParam(value="filters",required=false) String filters)
的_search参数被触发,通过过滤器工具栏上的真实值时,输入的搜索串
另一种方法处理这些过滤器是被搜索将此选项设置为false列/场stringResult选项为假设置为
jQuery("#grid_id").jqGrid('filterToolbar', {stringResult: false});
并且搜索字符串作为名称值对传递
因此,在这种情况下,我们正在搜索countryCode,我们正在搜索的字符串是ind。
所以函数签名会变成
@RequestMapping(value= "/cityData", method = RequestMethod.POST)
public @ResponseBody PageResponse getCityList(@RequestParam("page") int pageNo,
@RequestParam("rows") int rowLimit,
@RequestParam("sidx") String sortCol,
@RequestParam("sord") String sortDir,
@RequestParam("_search") boolean search,
//capturing the search string for the country code column @RequestParam(value="countryCode",required=false) String countryCode,)
希望这有助于有人!
感谢您指出我一个非常好的资源。 – 2012-04-02 07:25:39
@Anand:不客气!我自己并没有在春季开发,但我希望这个链接能帮助你一点。 – Oleg 2012-04-02 07:32:27