首先先将easyui 引入到jsp页面中

<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="easyui/demo.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>

<!--将一些英文转变为中文格式引入下面的js即可c-->
<script type="text/javascript" src="js/easyui-lang-zh_CN.js"></script>

第二步:

找到对应的easyui demo 复制代码 1 <div id="table" align="center"> 2 <table id="dg" class="easyui-datagrid" title="公告信息列表"

  jsp页面

<div id="table" align="center">
    <table id="dg" class="easyui-datagrid" title="公告信息列表"

       style="width:100%;height:400px"

             data-options="
rownumbers:true,
url:'notice/findNotice',url地址
method:'post',请求方式
pagination:true,
pageSize:10,每页数据条数
pageList:[5,10,15],
toolbar:'#tb',在头部添加查询条件
footer:'#ft'" 在尾部添加一些功能按钮
>
<thead>
<tr>
<th data-options="field:'ck',checkbox:'true'"></th> 加入多选款
<th data-options="field:'code',width:120">编号</th>
<th data-options="field:'title',width:120" align="center">标题</th>
<th data-options="field:'currentStrTime',width:150" align="center">发布时间</th>
<th data-options="field:'creater',width:100," align="center">发布人</th>
<th data-options="field:'content',width:260" align="center">内容</th>
<th data-options="field:'status',width:60,align:'center'"
align="center">公告状态</th>
</tr>
</thead>
</table>
<!--头部的查询条件按钮(可删除不要)-->
<div id="tb" style="padding:2px 5px;">
时间段 从: <input id="time1" class="easyui-datebox" style="width:130px">
到: <input id="time2" class="easyui-datebox" style="width:130px">
创建者/部门: <select id="dep" class="easyui-combobox" panelHeight="auto"
style="width:130px">
<option value="0">--请选择--</option>
<c:forEach items="${deps}" var="dep">
<option value="${dep.name}">${dep.name}</option>
</c:forEach>
</select> <a href="javascript:void(0)" onclick="searchNotice()"
class="easyui-linkbutton" iconCls="icon-search">查询</a>
</div>
<!--尾部的的功能按钮(可删除不要)需要的自行写或者查询easyui API-- >
<div id="ft" style="padding:2px 3px;">
<shiro:hasPermission name="notice:add">
<a href="notice/toAdd" class="easyui-linkbutton" iconCls="icon-add"
plain="true">添加</a>
</shiro:hasPermission>
<shiro:hasPermission name="notice:update">
<a href="javacsript:void(0)" onclick="updateNotice()"
class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a>
</shiro:hasPermission>
<shiro:hasPermission name="notice:delete">
<a href="javacsript:void(0)" onclick="deleteNotice()"
class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
</shiro:hasPermission>
<shiro:hasPermission name="notice:list">
<a href="javacsript:void(0)" onclick="findNotice()" class="easyui-linkbutton" iconCls="icon-save"
plain="true">查看</a>
</shiro:hasPermission>
</div>
</div>

第三步 java代码(无条件分页查询)注意返回的是json格式的数据 rows(需要返回的数据)和 total (数据的总记录数)

@RequestMapping("/findNotice")
@RequiresPermissions("notice:list")
@ResponseBody
public Map<String,Object> findNotice(NoticeBean noticeBean) {
System.out.println(noticeBean);
Map<String,Object> map=new HashMap<String, Object>();
int total=0;
List<Notice> list=null; total=noticeService.findTotalBySearch(noticeBean);
list=noticeService.findByPageSearch(noticeBean);
System.out.println(total);
System.out.println(list); map.put("rows", list);
map.put("total",total);
return map; }

有条件的分页查询(可参考我的,也可自行)

@RequestMapping("/findNotice")
@RequiresPermissions("notice:list")
@ResponseBody
public Map<String,Object> findNotice(NoticeBean noticeBean) {
System.out.println(noticeBean);
Map<String,Object> map=new HashMap<String, Object>();
int total=0;
List<Notice> list=null;
if((noticeBean.getTime1()==null || "".equals(noticeBean.getTime1()))&&(noticeBean.getCreater()==null ||"0".equals(noticeBean.getCreater())||"".equals(noticeBean.getCreater()))){
total=noticeService.findTotal();
list=noticeService.findPage(noticeBean.getPage(),noticeBean.getRows());
}else{
total=noticeService.findTotalBySearch(noticeBean);
list=noticeService.findByPageSearch(noticeBean);
System.out.println(total);
System.out.println(list);
}
map.put("rows", list);
map.put("total",total);
return map; }

获得多选框选择的数据

var rows = $('#dg').datagrid('getSelections');
for(var i=0; i<rows.length; i++){
var code=rows[i].code;

}

获得时间框数据

$('#time1').datebox('getValue')

获得下拉框数据

$('#dep').combobox('getValue')

其他的自行查看API

官网 http://www.jeasyui.net

关于easyui datagrid 表格数据处理的更多相关文章

  1. 一步步实现 easyui datagrid表格宽度自适应,效果非常好

    一步步实现 easyui datagrid表格宽度自适应,效果非常好: 一.设置公共方法,使得datagrid的属性  fitColumns:true $(function(){ //初始加载,表格宽 ...

  2. easyui datagrid 表格适应屏幕

    1.项目后台系统使用easyui,datagrid 的数据设置为自动适应屏幕,那么对于笔记本的话,就会显得有的小,可以通过设置datagrid属性,进行固定长度的设置 $('#gridTable'). ...

  3. EasyUi datagrid 表格分页例子

    1.首先引入 easyui的 css 和 js 文件 2.前台 需要写的js //源数据 function Async(action,args,callback){  $.ajax({  url: a ...

  4. easyui Datagrid 表格高度计算及自适应页面的实现

    因为页面上既要计算表格的高度,又要自适应浏览器大小,之前都都采用固定表格高度,这样就会导致不同的分辨率电脑上看起来表格高矮不一, 所以采用了计算网页高度和其他div 的高度之差作为表格的初始高度: H ...

  5. easyui datagrid 表格不让选中(双层嵌套)

    代码: function local(role,region,ip){ $("#roleList").datagrid({ // title:'服务器监控列表', height:( ...

  6. easyui datagrid 表格动态隐藏部分列的展示

    1.一套代码中,可能不同的项目情况都在用,但是可能不同的项目要求展示的datagrid列的内容并不一致,所以能够动态的显示部分datagrid列的内容. 即datagrid的中的某一列,这个项目要求显 ...

  7. easyui datagrid 表格组件列属性formatter和styler使用方法

    明确单元格DOM结构 要想弄清楚formatter和styler属性是怎么工作的,首先要弄清楚datagrid组件内容单元格的DOM接口,注意,这里指的是内容单元格,不包括标题单元格,标题单元格的结构 ...

  8. easyUI datagrid表格添加“暂无记录”显示

    扩展grid的onAfterRender事件 var myview = $.extend({}, $.fn.datagrid.defaults.view, {     onAfterRender: f ...

  9. easyui datagrid 表格中操作栏 按钮图标不显示

    jQuery EasyUI动态添加控件或者ajax加载页面后不能自动渲染 解决办法: 使用解析器 Parser(解析器) $.parser.parse();       // 解析所有页面 $.par ...

随机推荐

  1. VirtualBox内ubuntu10.10系统和windows7 共享文件夹

    材料 virtualbox 4.3.0 ubuntu10.10 window 7 sp1 步骤 1.安装好虚拟机和操作系统,(具体步骤网上有很多) 2.安装虚拟机的增强功能包, 安装完成手动系统重新, ...

  2. 【BZOJ-2597】剪刀石头布 最小费用最大流

    2597: [Wc2007]剪刀石头布 Time Limit: 20 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 1016  Solved:  ...

  3. 偷懒小工具 - SSO单点登录通用类(可跨域)

    写在前面的话 上次发布过一篇同样标题的文章.但是因为跨域方面做得不太理想.我进行了修改,并重新分享给大家. 如果这篇文章对您有所帮助,请您点击一下推荐.以便有动力分享出更多的"偷懒小工具&q ...

  4. Oracle 性能优化

    (1)      选择最有效率的表名顺序(只在基于规则的优化器中有效):ORACLE的解析器按照从右到左的顺序处理FROM子句中的表名,FROM子句中写在最后的表(基础表 driving table) ...

  5. PHP编码规范PSR-1

    .note-content { font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", STHeit ...

  6. CSS-垂直|水平居中问题的解决方法总结

    题外话:前两天和专业老师探讨最近的一个项目,涉及到对一个浮动的盒子局中的问题,老师的解决方法打开了我的新思路.让我有了总结一下平时的居中问题的想法.不然可能忘掉了以后又要到处寻找解决办法了.另外也给我 ...

  7. BZOJ3879: SvT

    后缀数组裸题,每次的查询单调栈扫一遍就完了.为什么要写虚后缀树= =后缀数组不是自带虚树的结构么= = #include<cstdio> #include<algorithm> ...

  8. logistic regression与SVM

    Logistic模型和SVM都是用于二分类,现在大概说一下两者的区别 ① 寻找最优超平面的方法不同 形象点说,Logistic模型找的那个超平面,是尽量让所有点都远离它,而SVM寻找的那个超平面,是只 ...

  9. git文件迁移到新架构

    环境: ubuntu16.04 代码托管地址:git.oschina.net 迁移原因: git上某工程是一堆静态页面html,因为在ubuntu下缺乏git图形客户端,想使用eclipse集成的gi ...

  10. 各个浏览器显示版本(IE,火狐)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...