Search code examples
javajsonstruts2struts2-jquerystruts2-jquery-grid

Send More Search Parameters in Struts2 jQuery Grid


First time I am using Struts2 jQuery Grid for AJAX data table.

I have also some filter parameters exactly above table. How to send those params?

<s:select name="par1" list="filesList" label="Select File" accesskey="MyKey" id="par1"/>
<s:select name="par2" list="fileDataStatus" label="Select Status"/>
More Like StartDate And EndDate.

<s:url var="remoteurl" action="searchCSVDataList" escapeAmp="false">
     <s:param name="par1" value="%{par1}"></s:param>
     <s:param name="par2" value="%{par2}"></s:param>
</s:url>

<sjd:grid id="gridtable"
                caption="Customer Examples"
                dataType="json"
                href="%{remoteurl}"
                pager="true"
                gridModel="gridModel"
                rowList="10,15,20"
                rowNum="15"
                rownumbers="true">
                <sjd:gridColumn name="id" index="id" title="ID" width="200px;"/>
                <sjd:gridColumn name="name" index="name" title="Name" sortable="true" />
                <sjd:gridColumn name="country" index="country" title="Country" />
                <sjd:gridColumn name="city" index="city" title="City" />
                <sjd:gridColumn name="creditLimit" index="creditLimit" title="Credit Limit" />
    </sjd:grid>

How to send those par1 and par2 in JqGrid Action? I have also tried with <s:url> tag but its not working.


Solution

  • Here is The Perfect Answer. I just Discovered it.

    You need to create form. and put all fields which you want to send with request.

    And Give that form id to jqGrid as formIds.

    <form id="myForm">
            <s:select label="Select a month" 
                  headerKey="-1" 
                  headerValue="Select Month"
                  list="#{'1':'Jan', '2':'Feb', '3':'Mar', '4':'Apr'}" 
                  name="yourMonth" 
                  value="2" 
                  id="selectedMonth"/>
                  <input type="text" name="par1" value="OOOOOOO1"/>
                  <input type="text" name="par2" value="OOOOOOO2"/>
    
                  <input type="submit" value="Submit"  onclick="myAjaxFunction();"/>    
        </form>
        <s:url var="remoteurl" action="jsontable" >
            <s:param name="par1">Kshitij</s:param>
        </s:url>
    
        <sjd:grid id="gridtable"
                    formIds="myForm"
                    caption="Customer Examples"
                    dataType="json"
                    href="%{remoteurl}"
                    pager="true"
                    gridModel="gridModel"
                    rowList="10,15,20"
                    rowNum="15"
                    rownumbers="true">
                    <sjd:gridColumn name="id" index="id" title="ID" width="200"/>
                    <sjd:gridColumn name="name" index="name" title="Name" sortable="true" />
                    <sjd:gridColumn name="country" index="country" title="Country" />
                    <sjd:gridColumn name="city" index="city" title="City" />
                    <sjd:gridColumn name="creditLimit" index="creditLimit" title="Credit Limit" />
        </sjd:grid>