关于easyui datagrid 表格数据处理
首先先将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 表格数据处理的更多相关文章
- 一步步实现 easyui datagrid表格宽度自适应,效果非常好
一步步实现 easyui datagrid表格宽度自适应,效果非常好: 一.设置公共方法,使得datagrid的属性 fitColumns:true $(function(){ //初始加载,表格宽 ...
- easyui datagrid 表格适应屏幕
1.项目后台系统使用easyui,datagrid 的数据设置为自动适应屏幕,那么对于笔记本的话,就会显得有的小,可以通过设置datagrid属性,进行固定长度的设置 $('#gridTable'). ...
- EasyUi datagrid 表格分页例子
1.首先引入 easyui的 css 和 js 文件 2.前台 需要写的js //源数据 function Async(action,args,callback){ $.ajax({ url: a ...
- easyui Datagrid 表格高度计算及自适应页面的实现
因为页面上既要计算表格的高度,又要自适应浏览器大小,之前都都采用固定表格高度,这样就会导致不同的分辨率电脑上看起来表格高矮不一, 所以采用了计算网页高度和其他div 的高度之差作为表格的初始高度: H ...
- easyui datagrid 表格不让选中(双层嵌套)
代码: function local(role,region,ip){ $("#roleList").datagrid({ // title:'服务器监控列表', height:( ...
- easyui datagrid 表格动态隐藏部分列的展示
1.一套代码中,可能不同的项目情况都在用,但是可能不同的项目要求展示的datagrid列的内容并不一致,所以能够动态的显示部分datagrid列的内容. 即datagrid的中的某一列,这个项目要求显 ...
- easyui datagrid 表格组件列属性formatter和styler使用方法
明确单元格DOM结构 要想弄清楚formatter和styler属性是怎么工作的,首先要弄清楚datagrid组件内容单元格的DOM接口,注意,这里指的是内容单元格,不包括标题单元格,标题单元格的结构 ...
- easyUI datagrid表格添加“暂无记录”显示
扩展grid的onAfterRender事件 var myview = $.extend({}, $.fn.datagrid.defaults.view, { onAfterRender: f ...
- easyui datagrid 表格中操作栏 按钮图标不显示
jQuery EasyUI动态添加控件或者ajax加载页面后不能自动渲染 解决办法: 使用解析器 Parser(解析器) $.parser.parse(); // 解析所有页面 $.par ...
随机推荐
- android获取位置location为null的问题
12:38:542016-12-23 很多人经常遇到这种问题,主要是获取到位置的信息为null,第一个主要要有权限 <uses-permission android:name="a ...
- JAVA面向对象
JAVA面向对象 对象 我们生活中能看到能摸到的一切事物都是对象.在程序中模拟出生活中的所有东西万物皆对象 只要是对象--属性和行为(方法) 属性 对象有什么 例如:学生有姓名.学 ...
- Smarty模版引擎的原理
Smarty是一个使用php写出来的模版引擎,用来将原本与html代码混杂在一起PHP代码逻辑分离,实现前后端分离. Smarty模板优点: 1. 速度:采用Smarty编写的程序可以获得最大速度的提 ...
- 安装cocoapods及相关问题解决
申明:本博客大部分内容转载自简书http://www.jianshu.com/p/b64b4fd08d3c,但还有些问题博主在这里做了补充. Mac系统版本:10.12.1 一.什么是CocoaPod ...
- css3 圆角
-moz-border-radius: 15px; /* Gecko browsers */ -webkit-border-radius: 15px; /* Webkit browsers */ bo ...
- Win7硬盘整数分区一览表
10G=10245 MB 20G=20482 MB 30G=30726 MB 40G=40963 MB 50G=51208 MB 60G=61444 MB 70G=71681 MB 80G=81926 ...
- Angular 之坑??
1. 场景:bootstrap的popup画面中有一个select元素, <select > <option> 1 </option> <option ng- ...
- async await
参考:https://blogs.msdn.microsoft.com/windowsappdev_cn/2012/04/30/winrt-await/
- spring jdbc 查询结果返回对象、对象列表
首先,需要了解spring jdbc查询时,有三种回调方式来处理查询的结果集.可以参考 使用spring的JdbcTemplate进行查询的三种回调方式的比较,写得还不错. 1.返回对象(queryF ...
- 10个最常见的 HTML5 面试题及答案
这是选择了10个 HTML5 面试问题并给出了答案.这是 Web 开发人员最常见的面试问题,相信你掌握了这些重要的面试问题后一定会觉得你的理解提高了.一起来看看吧. 您可能感兴趣的相关文章 Web 前 ...