搬砖中的小事之代码(十)--EasyUI多条件组合查询的实现
2017-07-19 13:50
645 查看
EasyUI多条件组合查询实现:
下拉框使用select,添加属性class=”easyui-combobox”,其次设置默认值(也就是什么不选的时候),应该添加一个空的
只需要给option的属性value赋值为空串,写成:value=””
下面是具体的代码实现:
jsp页面代码:
对应的js获取字段的值写法:
其次在dao.xml的查询配置,注意加上每个字段的非空判断和trim()去除空格的判断:
部分代码实例:
下拉框使用select,添加属性class=”easyui-combobox”,其次设置默认值(也就是什么不选的时候),应该添加一个空的
只需要给option的属性value赋值为空串,写成:value=””
下面是具体的代码实现:
jsp页面代码:
<!-- 定义Grid --> <table id="customerdg"> </table> <div id="customertb" style="padding:2px 5px;"> <input id="customerCode" class="easyui-textbox" label="客户编码:" data-options="prompt:'客户编码...'" style="width:15%;"> <input id="customerNameShort" class="easyui-textbox" label="客户简称:" data-options="prompt:'客户简称...'" style="width:15%;"> <!-- 1、已立项;2、沟通中;3、已报卷;4、已上线;5、合作中止; --> <select id="customerStatus" class="easyui-combobox" style="width:200px;" name="status" data-options="prompt:'请选择...', label: '客户状态:', labelPosition: 'left' "> <!-- 添加默认选项--请选择,为不选择任何一个下拉框子选项 --> <option value="">请选择</option> <option value="1">已立项</option> <option value="2">沟通中</option> <option value="3">已报卷</option> <option value="4">已上线</option> <option value="5">合作中止</option> </select> <select id="customerChecked" class="easyui-combobox" style="width:200px;" name="checked" data-options="prompt:'请选择...', label: '审核状态:', labelPosition: 'left' "> <!-- 添加默认选项--请选择,为不选择任何一个下拉框子选项 --> <option value="">请选择</option> <option value="1">未审核</option> <option value="2">审核中</option> <option value="3">审核成功</option> <option value="4">审核失败</option> </select> <a id="customersearch" href="#" class="easyui-linkbutton" iconCls="icon-search">查询</a> </div>
对应的js获取字段的值写法:
//查询(四个搜索条件:客户编码+客户简称+客户状态+审核状态) $('#customersearch').bind("click", function(){ var obj = { "code": $("#customerCode").val()||undefined, "status": $("#customerStatus").val()||undefined, "checked": $("#customerChecked").val()||undefined, "nameShort": $("#customerNameShort").val()||undefined }; $('#customerdg').datagrid('load', obj ); });
其次在dao.xml的查询配置,注意加上每个字段的非空判断和trim()去除空格的判断:
部分代码实例:
<select id="queryList" resultMap="BaseResultMap"> select * from crm_customer <where> deleted=0 <if test="code != null and code.trim() !=''" > and code = #{code} </if> <if test="name != null and name.trim() !=''"> and name = #{name} </if> <if test="nameShort != null and nameShort.trim() !=''"> and name_short like CONCAT(CONCAT('%', #{nameShort}), '%') </if> <if test="status != null and status.trim() !=''"> and status = #{status} </if> <if test="checked != null and checked.trim() !=''"> and checked = #{checked} </if> </where> <if test="order != null and sort != null "> order by ${sort} ${order} </if> <if test="offset != null and limit != null "> limit #{offset}, #{limit} </if> </select>
相关文章推荐
- EasyUi+Spring Data 实现按条件分页查询的实例代码
- 利用hibernate实现多条件组合查询的两种方式(2017年5月18日22:45:09)
- PowerBuilder中通用组合条件查询模板的实现
- PB源码:简单实现多种条件“组合查询”
- PHP实现多条件查询实例代码
- ASP多条件查询功能实现代码(多关键词查询)
- [easyUI]日期条件查询&实现下载弹窗
- [EasyUI系列]EasyUI datagrid多条件查询实现
- 【重点###】SpringDataJPA的组合条件分页查询(笔记思路,便于忘了复习)页面:EasyUI
- PHP组合查询多条件查询实例代码第1/2页
- 用iBatis实现多条件自由组合查询
- 搬砖中的小事之代码(六)--列表显示的字段与数据库中字段类型不匹配,需要在查询后进行简单转换
- PHP实现多条件查询实例代码
- struts2实现条件查询分页代码
- ASP多条件查询功能实现代码(多关键词查询)
- 在easyUI中把form表单转换成json数据利用datagrid的load方法实现条件查询
- 这个多条件不确定查询功能怎么实现,写的代码还有问题
- EasyUi+Spring Data 实现按条件分页查询