how to implement filter Search using Struts2 Jquery Plugin

北城以北 提交于 2019-12-11 04:48:33

问题


I am trying to implement filter search for my Struts2 jquery grid. If I search any string (through jquery filter textbox) then it is calling my action class but i am unable to get the search string in my action class. I tried to print this line inside my Action class but the Search String is not appearing in my Action class.

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

Please help me for this, i tried a lot ,and still am trying for it.. My Code:

Subjectinfo.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>

回答1:


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

When the stringResult option is set to true the data posted to the server is a string and the structure of the posted data is the same as in Advanced Search.

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.



来源:https://stackoverflow.com/questions/13026959/how-to-implement-filter-search-using-struts2-jquery-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!