接我的上篇博客  EasyUI_使用datagrid分页 (Day_28) .

按惯例,我们先看效果图

EasyUI 实现多条件分页很简单。

我们先来通过官网了解下这两个属性:

显然,有了load 方法后,什么Ajax啥的都没有它来的方便。它会将响应的数据加载到datagrid中,datagrid会自动的请求URL路径,从而实现带条件分页。

tt是我的表格,{}内是传递的参数。

 $('#tt').datagrid('load',{"sName":sName,"sMaxWeight":sMaxWeight,"sMinWeight":sMinWeight,"sUid":sUid});

于是,我们实现多条件分页可大致分为这么几个步骤

1、获取文本框中输入要查询的文本值

2、使用datagrid的load方法,发送参数

3、数据自动重新加载

接下来上代码

先上jsp:

 1 //表格
2 <table id="tt"
3 class="easyui-datagrid"
4 striped="true"
5 url="/jsp/Standard/StandardAll"
6 toolbar="#tb"
7 pagination="true"
8 pageList="[1,2,3]"
9 fit="true">
10 <thead>
11 <tr>
12 <th field="id" width="120" align="center" checkbox="true">编号</th>
13 <th field="name" width="120" align="center">收派名称</th>
14 <th field="minweight" width="120" align="center">最小重量</th>
15 <th field="maxweight" width="120" align="center">最大重量</th>
16 <th field="user_id" width="120" align="center">操作人</th>
17 <th field="updatetime" width="150" align="center">操作时间</th>
18 </tr>
19 </thead>
20 </table>
21
22 <%--侧边栏查询区域--%>
23 <div data-options="region:'east',iconCls:'icon-search',title:'搜索栏',split:true" style="width:300px;">
24 <div region="center" border="false" style="padding: 10px;">
25 <table cellpadding=6>
26 <tr><input id="11" type="text" style="display:none;"/></tr>
27 <tr>
28 <td>收派标准名称:</td>
29 <td><input id="sName" name="sName" type="text" class="txt01"/></td>
30 </tr>
31 <tr>
32 <td>最大重量:</td>
33 <td><input id="sMaxWeight" name="sMaxWeight" type="text" class="txt01"/></td>
34 </tr>
35 <tr>
36 <td>最小重量:</td>
37 <td><input id="sMinWeight" name="sMinWeight" type="text" class="txt01"/></td>
38 </tr>
39 <tr>
40 <td>操作人:</td>
41 <td><input id="sUid" name="sUid" type="text" class="txt01"/></td>
42 </tr>
43 <tr>
44 <td align="right"><a class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="seach()">查询</a></td>
45 <td align="right"><a class="easyui-linkbutton" iconCls="icon-reload" plain="true" type="reset" onclick="reset()">重置</a></td>
46 </tr>
47 </table>
48 </div>
49 </div>

查询方法: 将需要做查询的参数获取,传递。

1  /*带分页查询*/
2 function seach() {
3 var sName=$('#sName').val();
4 var sMaxWeight=$('#sMaxWeight').val();
5 var sMinWeight=$('#sMinWeight').val();
6 var sUid=$('#sUid').val();
7 $('#tt').datagrid('load',{"sName":sName,"sMaxWeight":sMaxWeight,"sMinWeight":sMinWeight,"sUid":sUid});
8 }

Controller层:

 1 @RequestMapping("StandardAll")
2 @ResponseBody
3 public Object StandardAll(Integer page,Integer rows,String sName,String sMaxWeight,String sMinWeight,String sUid)
4 {
5
6
7 Page<Standard> pageInfo = PageHelper.startPage(page, rows);
8 /*获得所有取派信息*/
9 List<Standard> list = standardService.SelAll(sName,sMaxWeight,sMinWeight,sUid);
10 /*获取总记录条数,将结果响应给浏览器 json格式*/
11 long total = pageInfo.getTotal();
12 /*封装在map中*/
13 Map<String,Object> map=new HashMap<String,Object>();
14 /*前面我们知道,pagination 分页是根据rows,pages,所以只需根据map 键值对的特点来找到rows*/
15 map.put("rows",list);
16 map.put("total",total);
17 return JSON.toJSON(map);
18 }

Service层:

1 public List<Standard> SelAll(String sName,String sMaxWeight,String sMinWeight,String sUid);

Service 实现类: 名称做模糊查询,具体的数值做精确查询

 1     public List<Standard> SelAll(String sName,String sMaxWeight,String sMinWeight,String sUid) {
2 StandardExample standardExample=new StandardExample();
3 StandardExample.Criteria criteria = standardExample.createCriteria();
4 //默认筛选状态为0,也就是可用的取派标准信息
5 criteria.andDeltagEqualTo("0");
6 //判断,当它们非空时,添加条件筛选
7 if (sName!=null&&!(sName.equals("")))
8 {
9
10 criteria.andNameLike("%"+sName+"%");
11 }
12 if (sMaxWeight!=null&&!(sMaxWeight.equals("")))
13 {
14 criteria.andMaxweightEqualTo(Double.parseDouble(sMaxWeight));
15 }
16 if (sMinWeight!=null&&!(sMinWeight.equals("")))
17 {
18 criteria.andMinweightEqualTo(Double.parseDouble(sMinWeight));
19 }
20 if (sUid!=null&&!(sUid.equals("")))
21 {
22 criteria.andUser_idLike(sUid);
23 }
24 List<Standard> ListStandardList = standardMapper.selectByExample(standardExample);
25 return ListStandardList;
26 }

好,使用easyui  datagrid 分页就告一段落了。

有什么不懂可以私信博主。

多条件分页 (Day_31)的更多相关文章

  1. AspNetPager 多条件分页查询

    AspNetPager 这个分页控件一般做后台基本都知道的,我就不多说了(说明与下载链接:http://www.webdiyer.com/Controls/AspNetPager),嘿嘿!其实我也是刚 ...

  2. asp.net mvc多条件+分页查询解决方案

    开发环境vs2010 css:bootstrap js:jquery bootstrap paginator 原先只是想做个mvc的分页,但是一般的数据展现都需要检索条件,而且是多个条件,所以就变成了 ...

  3. 【java】spring-data-jpa 集成hibernate实现多条件分页查询

    初次接触spring-data-jpa,实现多条件分页查询. 基础环境 Spring Boot+spring-data-jpa+hibernate+mysql 1.接口 要继承这个接口,这个接口提供了 ...

  4. 重构MVC多条件分页解决方案

    重构MVC多条件+分页解决方案 为支持MVC的验证,无刷新查询,EF,以及让代码可读性更强一点,所以就重构了下原来的解决方案. 这里就简单讲下使用方法吧: Model: 继承PagerBase:  S ...

  5. MVC+Bootstrap+Drapper使用PagedList.Mvc支持多查询条件分页

    前几天做一个小小小项目,使用了MVC+Bootstrap,以前做分页都是异步加载Mvc部分视图的方式,因为这个是小项目,就随便一点.一般的列表页面,少不了有查询条件,下面分享下Drapper+Page ...

  6. springboot+thymeleaf+pageHelper带条件分页查询

    html层 <div> <a class="num"><b th:text="'共 '+ ${result.resultMap['pages ...

  7. [工作日志] 2018-11-30 重要: 1. 多条件+ 分页 + 多表联查 2. idea拉新分支

    多条件+ 分页 + 多表联查 多条件查询 1.pom依赖 <dependency> <groupId>commons-dbutils</groupId> <a ...

  8. .NetCore 分页控件实现原理处理以及条件分页处理

    说明 自定义一个类继承TagHelper,注意自定义类的 必须以TagHelper结尾,这个有点类是属性 Attribute的写法 protected TagHelper(); // // 摘要: / ...

  9. thinkphp 带条件分页查询

    thinkphp 带条件分页查询:form表单传值时候,method='get'. 用 get 传值

随机推荐

  1. 这可能是最容易理解的 Go Mutex 源码剖析

    Hi,大家好,我是 haohongfan. 上一篇文章<一文完全掌握 Go math/rand>,我们知道 math/rand 的 global rand 有一个全局锁,我的文章里面有一句 ...

  2. 6. Mybatis resultMap

    resultMap 元素是MyBatis中最重要最强大的元素.它就是让你远离90%的需要从结果集中取出数据的JDBC代码的那东西,而且在一些情形下允许你做一些JDBC不支持的事情.事实上,编写相似于对 ...

  3. [Vue warn]: Unknown custom element: <terminal-process> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

    Vue组件注册报错问题 import 不要加{},排查出如果页面引用单个组件的时候不要加上{}中括号,引入多个组件时才能派上用场,中括号去除问题即可解决.

  4. struct 模块

    1. Struct 简介 2. Struct 代码示例 2.1 struct.pack 2.2 struct.unpack 2.3 struct.calcsize 1. Struct 简介 当 pyt ...

  5. 【布隆过滤器】基于Hutool库实现的布隆过滤器Demo

    布隆过滤器出现的背景: 如果想判断一个元素是不是在一个集合里,一般想到的是将集合中所有元素保存起来,然后通过比较确定.链表.树.散列表(又叫哈希表,Hash table)等等数据结构都是这种思路,存储 ...

  6. LA3403天平难题(4个DFS)

    题意:      给出房间的宽度r和每个吊坠的重量wi,设计一个尽量宽但宽度不能超过房间宽度的天平,挂着所有挂坠,每个天平的一段要么挂这一个吊坠,要么挂着另一个天平,每个天平的总长度是1,细节我给出题 ...

  7. hdu3074 线段树求区间乘积(单点更新)

    题意:       给你n个数,两种操作,(1) 把第b个数改成c (2)算出b-c的乘积,结果对1000000007取余. 思路:       线段树单点更新,简单题目,不多解释,具体看代码. #i ...

  8. Windows核心编程 第二十章 DLL的高级操作技术

    第2 0章 D L L的高级操作技术 看了下这章的内容,谈不上高级,都是些常用相关,但是还是有一些细节需要注意. 20.1 DLL模块的显式加载和符号链接 如果线程需要调用D L L模块中的函数,那么 ...

  9. Windows核心编程 第七章 线程的调度、优先级和亲缘性(上)

    第7章 线程的调度.优先级和亲缘性 抢占式操作系统必须使用某种算法来确定哪些线程应该在何时调度和运行多长时间.本章将要介绍Microsoft Windows 98和Windows 2000使用的一些算 ...

  10. <JVM中篇:字节码与类的加载篇>04-再谈类的加载器

    笔记来源:尚硅谷JVM全套教程,百万播放,全网巅峰(宋红康详解java虚拟机) 同步更新:https://gitee.com/vectorx/NOTE_JVM https://codechina.cs ...