zoukankan      html  css  js  c++  java
  • jqgrid 自定义文本框、选择框等查询

    要实现jqgrid的自定义查询可通过表格获取查询的条件,再给jqgrid表格发送postData参数。

    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").click(function () {
                var queryParams = jgGrid.getGridParam();                        //取到jqgrid的参数
                queryParams["postData"].params =  $("#querytable").formobj();    //把查询条件表格的数据给过去
                $("#list2").jqGrid('setGridParam', {                            //jqgrid表格执行方法把条件参数传过去
                     datatype:'json' ,
                     postData:queryParams
                }).trigger('reloadGrid');    //刷新表格
            });

    这样写了之后,还得在sql语句中加入if判断:

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

    即可。

  • 相关阅读:
    python引用.py文件
    推荐系统之矩阵分解 转载 特别好
    数据挖掘之一元线性回归 python代码
    system服务文件讲解 转载
    bin sbin /usr/bin /usr/sbin区别 转载
    linux设置部门(或者学生部门)的共享目录
    Error establishing a database connection wordpress网站出现这个问题centos7的
    tomcat的java项目部署位置
    MAMP PRO教程
    MAMP使用简单教程
  • 原文地址:https://www.cnblogs.com/lintu-kong/p/12130976.html
Copyright © 2011-2022 走看看