Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Search jqGrid过滤器工具栏与Spring3MVC的集成_Search_Spring Mvc_Jqgrid - Fatal编程技术网

Search 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

如何捕获jqGrid工具栏搜索中搜索的字段的值

我正在使用Spring3MVC进行后端工作

目前我的方法签名看起来像

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:不客气!我自己不是在春季开发的,但我希望这个链接能对您有所帮助。