关于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 ...
随机推荐
- Mybatis传入参数类型为Map
mybatis更新sql语句: <update id="publishT00_notice" parameterType="Map"> update ...
- oracle 修改字符集支持中文
1.登录sys关闭服务 [oracle@t-e ~]$ export ORACLE_SID=kamiltest1 [oracle@t-e ~]$ sqlplus / as sysdba SQL> ...
- HDU 3669 Cross the Wall
题目大意 给定 \(N\) 个矩形的宽和高, \((h_1, w_1), (h_2, w_2), \dots, (h_n w_n)\) . 现需要确定 \(k\) (\(k \le K\), \(K\ ...
- css常用属性汇总
一.常用css属性 (1) *block(区块) 行高 line-height:数值 | inherit | normal; 字间距 letter-spacing: 数值 | inherit | no ...
- IOS-Hybrid(混合开发)
http://www.cnblogs.com/oc-bowen/p/5423902.html 1.1. APP三种开发模式 智能手机之普及不用多说,手机APP渗投到各个行业:电商(淘宝.京东等 ...
- new bird in github
首次使用先要建立本地github信息: git config - -global user.name newbird git config - -global user.email newbir ...
- HTTP压力测试工具
HttpTest4Net是一款基于C#实现的和HTTP压力测试工具,通过工具可以简单地对HTTP服务进行一个压力测试.虽然VS.NET也集成了压力测试项目,但由于VS自身占用的资源导致了在配置不高的P ...
- 如何更改gnome-screenshot的默认的保存路径?
参考这篇文章: http://www.itye.org/archives/3121 首先, 在dconf-editor中设置, screenshot的自动保存路径: auto-save-directo ...
- Codeforces Round #352 (Div. 2) ABCD
Problems # Name A Summer Camp standard input/output 1 s, 256 MB x3197 B Different is Good ...
- 认识Android Service
一.使用Service 1.什么是Service以及Service的配置项: Service是Android组件的一种,派生自android.app.service类.它不提供交互界面,只是在后台运 ...