搬砖中的小事之代码(十)--EasyUI多条件组合查询的实现
来源:互联网 发布:intent的传递数据 编辑:程序博客网 时间:2024/05/17 18:27
EasyUI多条件组合查询实现:
下拉框使用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>
阅读全文
0 0
- 搬砖中的小事之代码(十)--EasyUI多条件组合查询的实现
- 搬砖中的小事之代码(一)--枚举
- 搬砖中的小事之代码(四)--useGeneratedKeys的理解与使用
- 搬砖中的小事之代码(五)--maven项目的各种异常以及解决办法
- 搬砖中的小事之代码(七)---设置数据库中非空字段的默认值
- 搬砖中的小事之代码(六)--列表显示的字段与数据库中字段类型不匹配,需要在查询后进行简单转换
- 搬砖中的小事之代码(九)--改进八的客户编码随机串的生成方法
- 搬砖中的小事之工具(一)--secureCRT中文乱码问题的解决
- 搬砖中的小事之工具(二)--tomcat端口被占用问题的解决
- 搬砖中的小事之前端(一)--name和value和type的区别
- asp中的多条件组合查询实现
- 搬砖中的小事之代码(八)--客户编码6位数的随机串的生成和登记时间的生成
- 搬砖中的小事之代码(二)--报错Consider defining a bean of type...in your configuration
- 搬砖中的小事(四)之工具--通过打开的文件进入其所在的目录配置
- 搬砖中的小事之前端(二)--margin属性信手拈来的使用--
- lucene查询之 多条件查询 BooleanQuery 可以组合查询条件。及代码示例
- 蛙蛙推荐:asp中的多条件组合查询实现
- 【重点###】SpringDataJPA的组合条件分页查询(笔记思路,便于忘了复习)页面:EasyUI
- MFC 修改对话框的背景颜色及透明度
- cocos2d-x (二) 使用Delegate(委托)
- cesium地图缩放,旋转,倾斜
- Android App优化之ANR详解
- ckeditor
- 搬砖中的小事之代码(十)--EasyUI多条件组合查询的实现
- UNIX网络编程卷1:套接字联网-第7章:套接字选项
- CMD技巧
- Android学习(十一)RadioButton和RadioGroup
- VBScript技巧
- 自用基础5-数组+for each
- leetcode(7) reverse integer
- IOS部分异常处理
- 292. Nim Game