jquery easyui datagrid 分页 详解(java)
1、首先引入easyui包,可以在官方网站下载,http://www.jeasyui.com/download/index.php
<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
<script type="text/javascript" src="js/jquery-easyui-1.3.2/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="js/jquery-easyui-1.3.2/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/jquery-easyui-1.3.2/locale/easyui-lang-zh_CN.js"></script>
注意:jquery-1.8.0.min.js要在jquery.easyui.min.js之前引入。
2、Create datagrid from an existing table element, defining columns, rows, and data in html.
<table id="dg"
title="社团基本信息"
class="easyui-datagrid"
style="width:1200px;height:600px;"
url="list"
pagination="true"
rownumbers="true"
fitColumns="true"
singleSelect="true">
<thead>
<tr>
<th field="stu_id" width="40">学号</th>
<th field="stu_name" width="50">姓名</th>
<th field="stu_yuanxi" width="50">院系</th>
<th field="stu_email" width="80">Email</th>
<th field="stu_phone" width="50">电话</th>
<th field="stu_qq" width="40">QQ</th>
<th field="stu_sex" width="20">性别</th>
<th field="stu_age" width="40">出生年月</th>
<th field="stu_join" width="40">参加时间</th>
<th field="depart_name" width="50">所在社团</th>
<th field="stu_job" width="50">职务</th>
<th field="stu_like" width="50">爱好</th>
</tr>
</thead>
</table>
3、表student对应的实体
public class Student {
private int id;
private String stu_id;
private String stu_name;
private String stu_password;
private String stu_yuanxi;
private String stu_job;
private String stu_email;
private String stu_phone;
private String stu_qq;
private String stu_sex;
private String stu_age;
private String depart_name;
private String role_name;
private int depart_id;
private int role_id;
private String stu_like;
private int u_id;
private String u_dept;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
......
}
4、DAO实现获取student记录
public List<Student> listStudent(int pageNumber,int pageSize){ List<Student> list=new ArrayList<Student>();
String sql="select * from student limit " + pageNumber+"," + pageSize ;
try {
list = runner.query(sql, new BeanListHandler<Student>(Student.class));
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
5、Servlet实现跳转,将数据返回给前台
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//处理乱码
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
int page;
try {
page = Integer.parseInt(request.getParameter("page"));
} catch (NumberFormatException e) {
page = 1;
}
int row;
try {
row = Integer.parseInt(request.getParameter("rows"));
} catch (NumberFormatException e) {
row = 10;
} PrintWriter out = response.getWriter(); //获得student列表
StudentInfoService studentInfoService = new StudentInfoService();
List<Student> list =studentInfoService.listStudent(page, row) ;
long total = studentInfoService.results() ; Map<String, Object> map = new HashMap<String, Object>();
map.put("total", total);
map.put("rows", list);
Gson gson = new Gson();
String json = gson.toJson(map);
out.write(json);
out.flush();
out.close();
}
6、前台效果图
jquery easyui datagrid 分页 详解(java)的更多相关文章
- jquery easyui datagrid 分页详解
由于项目原因,用了jquery easyui 感觉界面不错,皮肤样式少点,可是官网最近打不开了,资料比较少,给的demo没有想要的效果,今天在用datagrid 做分页显示的时候,折腾了半天,网上的资 ...
- jquery easyui datagrid 分页 详解
前些天用jquery easyui的table easyui-datagrid做分页显示的时候,折腾了很久,后来终于解决了.其实不难,最主要我不是很熟悉前端的东西. table easyui-data ...
- easyui datagrid 分页略解
easyui datagrid 本身自带了分页功能. 但是这个需要你自己控制. 在后台可以得到两个datagrid的参数,rows 和page.其中rows是每页要显示的个数,page是第几页.单纯的 ...
- jquery easyui datagrid 分页实现---善良公社项目
接着上篇文章,接下来给大家分享分页的实现,分页其实多多少少见过很有几种,框架中带的图片都特别的好看,会给用户以好的使用效果,具体实现,需要自己来补充代码: 图示1: 通常情况下页面数据的分页显示分成真 ...
- jquery easyui datagrid 分页实现
通常情况下页面数据的分页显示分成真假两种.真分页是依靠后台查询时控制调出数据的数量来实现分页,也就是说页面在后台对数据进行处理,仅传输当前需要页的数据到前台来显示.而假分页则是后台一次性将所有的数据一 ...
- JQuery easyui Datagrid 分页事件
easyui是Jquery中的一个轻量级UI插件,提供了一些诸如window.datagrid.button等控件.现在主要说说Datagrid中分页控件的使用. easyui中可以单独添加分页pag ...
- jQuery EasyUI datagrid实现本地分页的方法
http://www.codeweblog.com/jquery-easyui-datagrid%e5%ae%9e%e7%8e%b0%e6%9c%ac%e5%9c%b0%e5%88%86%e9%a1% ...
- jQuery Validate验证框架详解
转自:http://www.cnblogs.com/linjiqin/p/3431835.html jQuery校验官网地址:http://bassistance.de/jquery-plugins/ ...
- jquery easyui datagrid使用参考
jquery easyui datagrid使用参考 创建datagrid 在页面上添加一个div或table标签,然后用jquery获取这个标签,并初始化一个datagrid.代码如下: 页面上 ...
随机推荐
- mysql 内外链接
外联结:分为外左联结和外右联结. 左联结A.B表的意思就是将表A中的全部记录和表B中联结的字段与表A的联结字段符合联结条件的那些记录形成的记录集的联结,这里注意的是最后出来的记录集会包括表A的全部记录 ...
- 从gitbook将书籍导入到github中
gitbook自己的导出工具经常出问题,可直接使用git. 从gitbook中clone下书 $ git clone https://git.gitbook.com/username/name_of_ ...
- MPAndroidChart 的实现
效果图: 代码实现: package com.jiahao.me; import java.util.ArrayList; import java.util.List; import android. ...
- DataSource , DataSink, DataSourceLoop
Script assertion in login:
- sql 指令
SELECT 是用来做什么的呢?一个最经常使用的方式是将资料从数据库中的表格内选出.从这一句回答中.我们立即能够看到两个keyword:从 (FROM)数据库中的表格内选出 (SELECT).(表格是 ...
- esxi 5.1 由于断电错误无法启动 报错 bank5 invalid configuration
由于着急,处理过程中也没有截图,这里简单的描写叙述下整个过程吧. IBM pcserver x3850 可能是机器太热的原因,中午无故掉电,导致esxi无法正常启动 启动时报错 bank5 inval ...
- 解决Android上的QPython不能import urllib的问题
试用了一下QPython,感觉很强大,Kivy也包含进去了,下载一些第三方库也很方便,相对于SL4A来说确实先进了很多. 但是很快发现不能import urllib,提示大概是这样的内容: No mo ...
- Git Cmd
http://my.oschina.net/sunboy2050/blog/55749
- UVALive 7070 The E-pang Palace 暴力
The E-pang Palace Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/problem ...
- Android应用程序框架之无边界设计意图
Android的应用框架的外特性空间的描述在SDK文档有十分清楚的描述,Android应用的基本概念,组件生命周期等等有详细的描述.在外特性空间中,Android提供了Activity,Service ...