2

我正在尝试为我的 Struts2 jquery 网格实现过滤器搜索。如果我搜索任何字符串(通过 jquery 过滤器文本框),那么它正在调用我的操作类,但我无法在我的操作类中获取搜索字符串。我试图在我的 Action 类中打印这一行,但 Search String 没有出现在我的 Action 类中。

System.out.println("This line is getting printed But search textbox values is not printing."+searchString+""+searchField);

请为此帮助我,我尝试了很多,但仍在尝试。 我的代码:

主题信息.jsp

            <%@ page contentType="text/html; charset=UTF-8"%>
            <%@ taglib prefix="s" uri="/struts-tags"%>
            <%@ taglib prefix="sj" uri="/struts-jquery-tags"%> 
            <%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%> 
            <html>
            <head>
            <title>Hello World</title> 
            <style type="text/css">
            @import
            url(<%=request.getContextPath()%>/css/style1.css);
            </style> 
             <sj:head jqueryui="true" jquerytheme="le-frog"/> 
            </head>
            <body> 
                <div id="setpage"> <s:url id="editurl" action="nedit"/>
                    <s:url id="editurl" action="nedit"/>
                    <s:url  id="remoteurl" action="ntable"/>

                    <sjg:grid
                       id="gridtable"
                        caption="Customer Examples"
                        dataType="json"
                        filter="true" 
                        filterOptions="{ stringResult :true, 
                        searchOnEnter : false, 
                        enableClear : true, 


                        gridModel="gridModel"
                        rowList="10,15,20"
                        navigatorDelete="true">
                    <sjg:gridColumn name="id" index="subjectId" title="ID" formatter="integer" sortable="true" key="true" 
                                       search="true" searchoptions="{sopt:['eq']}" editable="true"  hidden="true"   />

                    <sjg:gridColumn name="subjectName" index="subjectName" title="Subject Name" sortable="true" search="true"
                                        editable="true"
                                        edittype="text" />
                    </sjg:grid> 

                    </div>
            </body>
            </html>
4

1 回答 1

1

来自http://www.trirand.com/jqgridwiki/doku.php?id=wiki:toolbar_searching

当 stringResult 选项设置为 true 时,发布到服务器的数据是一个字符串,并且发布的数据的结构与高级搜索中的相同。

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:advanced_searching#options

So I think your problem is that you are looking for searchString, but the jqgrid is sending a request variable called filters, which is a json string as described in the advanced search options link.

于 2013-07-03T22:36:14.603 回答