问题
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