Struts2 + easyui的DataGrid 分页
jsp页面
js代码:
- $(function() {
- $('#ff').hide();
- $('#tt').datagrid({
- title : '信息显示',
- iconCls : 'icon-save',
- width : 'auto',
- height : 'auto',
- pageSize:10,
- pageList : [ 5, 10, 15 ],
- nowrap : true,
- striped : true,
- collapsible : true,
- url : 'pecc/peccList.action',
- loadMsg : '数据装载中......',
- onLoadError : function() {
- alert('数据加载失败!');
- },
- sortName : 'code',
- sortOrder : 'desc',
- remoteSort : false,
- frozenColumns : [ [ {
- field : 'ck',
- checkbox : true
- } ] ],
- columns : [ [ {
- title : '车牌号',
- field : 'carNumber',
- width : '100',
- rowspan : 2,
- align : 'center'
- }, {
- title : '车主',
- field : 'carPer',
- width : '100',
- rowspan : 2,
- align : 'center'
- }, {
- title : '违章时间',
- field : 'pTime',
- width : '80',
- rowspan : 2,
- align : 'center'
- }, {
- title : '违章地点',
- field : 'pPlace',
- width : '220',
- rowspan : 2,
- align : 'center'
- }, {
- title : '违章原因',
- field : 'pCase',
- width : '220',
- rowspan : 2,
- align : 'center'
- }, {
- title : '来源',
- field : 'pOrg',
- width : '120',
- rowspan : 2,
- align : 'center'
- }, {
- title : '交警大队',
- field : 'pPer',
- width : '300',
- rowspan : 2,
- align : 'center'
- } ] ],
- pagination : true,
- rownumbers : true,
- toolbar : [ {
- text : '全部',
- iconCls : 'icon-ok',
- handler : function() {
- $('#tt').datagrid({
- url : 'pecc/peccList.action'
- });
- }
- }, '-', {
- text : '添加',
- iconCls : 'icon-add',
- handler : function() {
- openAdd();
- $('#ff').show();
- $('#ff').form('clear');
- $('#ff').appendTo('#aa');
- }
- }, '-', {
- text : '修改',
- iconCls : 'icon-edit',
- handler : getSelect
- }, '-', {
- text : '删除',
- iconCls : 'icon-remove',
- handler : del
- }, '-', {
- text : '查询',
- iconCls : 'icon-search',
- handler : function() {
- $('#query').window('open');
- }
- } ]
- });
- displayMsg();
- });
- function displayMsg() {
- $('#tt').datagrid('getPager').pagination({
- displayMsg : '当前显示从{from}到{to}共{total}记录'
- });
- }
Action 代码:
- @Controller
- @ParentPackage("mydefault")
- @Namespace("")
- public class Pecc extends ActionSupport {
- private static final long serialVersionUID = 1L;
- @Resource
- PerinfoService perinfoService;
- @Resource
- PeccancyService peccancyService;
- @Action("/pecc")
- public String peccList() {
- try {
- HttpServletRequest re = ServletActionContext.getRequest();
- HttpServletResponse response = ServletActionContext.getResponse();
- response.setCharacterEncoding("UTF-8");
- PrintWriter out = response.getWriter();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
- JSONArray jsonArray = new JSONArray();
- JSONObject jsonobj = new JSONObject();
- Map map = new HashMap();
- long all = perinfoService.getCount(map);
- String page = re.getParameter("page");
- String rows = re.getParameter("rows");
- // 当前页
- int intPage = Integer.parseInt((page == null || page == "0") ? "1" : page);
- // 每页显示条数
- int number = Integer.parseInt((rows == null || rows == "0") ? "10" : rows);
- // 每页的开始记录 第一页为1 第二页为number +1
- int start = (intPage - 1) * number;
- map.put("page", start);
- map.put("pageCount", number);
- List list = peccancyService.getList(map);
- for (Peccancy con : list) {
- jsonobj.put("id", con.getId());
- jsonobj.put("carNumber", con.getCarNumber());
- jsonobj.put("carPer", con.getCarPer());
- jsonobj.put("pTime", sdf.format(con.getPTime()));
- jsonobj.put("pPlace", con.getPPlace());
- jsonobj.put("pCase", con.getPCase());
- jsonobj.put("pOrg", con.getPOrg());
- jsonobj.put("pPer", con.getPPer());
- jsonArray.add(jsonobj);
- }
- Map json = new HashMap();
- json.put("total", all);// total键 存放总记录数,必须的
- json.put("rows", jsonArray);// rows键 存放每页记录 list
- jsonobj = JSONObject.fromObject(json);// 格式化result一定要是JSONObject
- out.print(jsonobj);
- out.flush();
- out.close();
- } catch (IOException e) {
- System.out.println(e);
- }
- return null;
- }
Struts.xml 配置:
- <</span>package name="mydefault" extends="struts-default">
- <</span>global-results>
- <</span>result name="exception">/index.jsp</</span>result>
- </</span>global-results>
- <</span>global-exception-mappings>
- <</span>exception-mapping exception="java.lang.Exception"
- result="exception" />
- </</span>global-exception-mappings>
- </</span>package>
版权声明:本文为博主原创文章,未经博主允许不得转载。
Struts2 + easyui的DataGrid 分页的更多相关文章
- SSh结合Easyui实现Datagrid的分页显示
近日学习Easyui,发现非常好用,界面很美观.将学习的心得在此写下,这篇博客写SSh结合Easyui实现Datagrid的分页显示,其他的例如添加.修改.删除.批量删除等功能将在后面的博客一一写来. ...
- schemaeasyui实例:SSh结合Easyui实现Datagrid的分页显示
查了好多资料,发现还是不全,干脆自己整理吧,最少保证在我的做法正确的,以免误导读者,也是给自己做个记载吧! 克日学习Easyui,发现非常好用,界面很雅观.将学习的心得在此写下,这篇博客写SSh结合E ...
- 实例:SSh结合Easyui实现Datagrid的分页显示
近日学习Easyui,发现非常好用,界面很美观.将学习的心得在此写下,这篇博客写SSh结合Easyui实现Datagrid的分页显示,其他的例如添加.修改.删除.批量删除等功能将在后面的博客一一写来. ...
- EasyUI表格DataGrid前端分页和后端分页的总结
Demo简介 Demo使用Java.Servlet为后台代码(数据库已添加数据),前端使用EasyUI框架,后台直接返回JSON数据给页面 1.配置Web.xml文件 <?xml version ...
- Easyui的datagrid结合hibernate实现数据分页
最近在学习easyui的使用,在学到datagrid的时候遇到了一些问题,终于抽点时间整理了一下,分享出来,请各位前辈高手多多指教! 1.先来看看效果,二话不说,上图直观! 2.easyui的data ...
- EasyUI的datagrid分页
EasyUI的datagrid分页 前台代码: <script type="text/javascript"> $(function () { //查询 search( ...
- easyui的datagrid分页写法小结
easyui的datagrid分页死活不起作用...沙雕了...不说了上代码 //关闭tab1打开tab2 查询Detail function refundDetail(){ $('#tt').tab ...
- 关于Jquery EasyUI中的DataGrid服务器端分页随记
一.关于DataGrid的分页和排序参数 对于分页参数不需要用户指定,程序在AJAX请求的时候会带上分页和排序需要的参数 每页显示条数:rows 当前页:page 排序字段:sort [multiS ...
- Easyui datagrid 修改分页组件的分页提示信息为中文
datagrid 修改分页组件的分页提示信息为中文 by:授客 QQ:1033553122 测试环境 jquery-easyui-1.5.3 问题描述 默认分页组件为英文展示,如下,希望改成中文展示 ...
随机推荐
- python 基础 7.4 os 模块
#/usr/bin/python #coding=utf8 #@Time :2017/11/11 3:15 #@Auther :liuzhenchuan #@File :os 模块.py im ...
- HTML--2图片热点,网页划区,拼接,表单
图片热点: 规划出图片上的一个区域,可以做出超链接,直接点击图片区域就可以完成跳转的效果. 示例: 网页划区: 在一个网页里,规划出一个区域用来展示另一个网页的内容. 示例: 网页的拼接: 在一个网络 ...
- js中scrollLeft、scrollWidth、offsetTop等相关位置属性的理解(转)
1.常见的事件位置属性 e.pageX——相对整个页面的坐标 注意:IE6.IE7.IE8无该属性 e.layerX——相对当前坐标系的border左上角开始的坐标 注意:在opera.IE6.IE7 ...
- DBUtils使用详解
https://blog.csdn.net/samjustin1/article/details/52220423 https://www.cnblogs.com/CQY1183344265/p/58 ...
- jQuery学习笔记(7)--表格展开关闭
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> &l ...
- ios导航栏问题
http://m.blog.csdn.net/article/details?id=47395605
- JavaScript如何判断非空
JavaScript判断非空的语句一般为: var elvis; if (typeof elvis !== "undefined" && elvis !== nul ...
- 【linux】如何查看进程运行在那颗cpu上
这里介绍一种方法查看进程运行在哪个cpu上, 首先top 然后按字母:f 按字母:j 回车即可 其中P列表示进程运行在哪个CPU上
- 关于引用WebLogic.jar时遇到NoClassDefFoundError问题的解决方法
前段时间在做一个项目开发时,需要用到weblogic.jndi.WLInitialContextFactory,所以按照以前的经验,将WebLogic.jar添加到Build Path中.可是在执行时 ...
- Apache NiFi 开发 处理器使用说明
NIFI的使用: 注意:FlowFile由[属性]和[内容]组成,在解析的过程中这个概念非常重要,因为有些组件操作的是属性,有些组件操作的是内容,在配置组件时Destination配置项的选择很重要, ...