Custom queries can be achieved jqgrid conditions to obtain query by form, to give form to send jqgrid postData parameters.
HTML:
<table id="querytable" border="0" cellspacing="0" cellpadding="0" class="table"> <tr> <td> <label>性别:</label> </td> <td> <select id="sex" name="sex"> <option value="1">男</option> <option value="2">女</option> </select> </td> </tr> <tr> <td> <label>部门</label> </td> <td> <input type="text" id="department" name="department"> </td> </tr> </table>
Js:
$ ( "# Find") the Click (. function () { var queryParams jgGrid.getGridParam = (); // get to jqgrid parameter . queryParams [ "postData"] params = $ ( "# querytable") formobj (). ; // the query to a table of data in the past . $ ( "# List2") the jqGrid ( 'setGridParam', { // jqGrid condition parameter table to perform the method pass over DataType: 'JSON', postData: queryParams }) Trigger. ( 'reloadGrid'); // refresh the table });
After this write, if the judge had to join in sql statement:
<select id="selectAll" parameterType="java.lang.Object" resultType="java.util.Map"> select name,sex,age,department from user <where><if test="params.sex!=null and params.sex!=''"> AND sex like '%'||#{params.sex}||'%' </if> <if test="params.department!=null and params.department!=''"> AND department like '%'||#{params.department}||'%' </if> </where> </select>
It can be.