Search jqGrid过滤器工具栏与Spring3MVC的集成
如何捕获jqGrid工具栏搜索中搜索的字段的值 我正在使用Spring3MVC进行后端工作 目前我的方法签名看起来像Search jqGrid过滤器工具栏与Spring3MVC的集成,search,spring-mvc,jqgrid,Search,Spring Mvc,Jqgrid,如何捕获jqGrid工具栏搜索中搜索的字段的值 我正在使用Spring3MVC进行后端工作 目前我的方法签名看起来像 public @ResponseBody PageResponse getEmpList( @RequestParam("page") int pageNo, @RequestParam("rows") int rowLimit, @RequestParam("sidx") String sortCol, @RequestParam("sord") String
public @ResponseBody PageResponse getEmpList(
@RequestParam("page") int pageNo, @RequestParam("rows") int rowLimit,
@RequestParam("sidx") String sortCol, @RequestParam("sord") String sortDir)
如何修改它以捕获各种搜索参数,即已搜索的字段和相应的搜索字符串
我正在使用jqGrid 4.3.1我建议您使用过滤器工具栏的选项
:
jQuery("#grid_id").jqGrid('filterToolbar', {stringResult: true});
在这种情况下,对服务器的请求参数将与对对话框的请求参数相同(使用multipleSearch:true
选项进行搜索)
我自己不使用Spring3MVC,但我认为您需要在getEmpList
的参数列表中添加额外的参数@RequestParam(value=“filters”,required=false)字符串过滤器。该参数的值是JSON字符串,您还应该将其反序列化(解析)为对象。(有关更多信息,请参阅)我建议您使用过滤器工具栏的选项:
jQuery("#grid_id").jqGrid('filterToolbar', {stringResult: true});
在这种情况下,对服务器的请求参数将与对对话框的请求参数相同(使用multipleSearch:true
选项进行搜索)
我自己不使用Spring3MVC,但我认为您需要在getEmpList
的参数列表中添加额外的参数@RequestParam(value=“filters”,required=false)字符串过滤器。该参数的值是JSON字符串,您还应该将其反序列化(解析)为对象。(有关更多信息,请参阅)我正在回答我自己提出的问题
有两种方法可以捕获过滤器参数
如果将stringResult选项设置为true,如中所示
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参数触发为真值
处理这些过滤器的另一种方法是将stringResult选项设置为false,如中所示
jQuery("#grid_id").jqGrid('filterToolbar', {stringResult: false});
通过将此选项设置为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,)
希望这能帮助一些人 我正在回答我自己提出的问题
有两种方法可以捕获过滤器参数
如果将stringResult选项设置为true,如中所示
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参数触发为真值
处理这些过滤器的另一种方法是将stringResult选项设置为false,如中所示
jQuery("#grid_id").jqGrid('filterToolbar', {stringResult: false});
通过将此选项设置为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,)
希望这能帮助一些人 @Anand:不客气!我自己不是在春季开发的,但我希望链接能对您有所帮助。@Anand:不客气!我自己不是在春季开发的,但我希望这个链接能对您有所帮助。