jsp页面,引入几个js

<link type="text/css" rel="stylesheet" href="/library/css/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="/library/plugins/datatables/dataTables.bootstrap.css">
<script type="text/javascript" src="/library/plugins/datatables/jQuery-2.1.4.min.js"></script>
<script type="text/javascript" src="/library/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/library/plugins/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/library/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="/library/plugins/datatables/common.js"></script> var ctx = "${pageContext.request.contextPath}";

并且写一个用于分页的table

<div style="margin-top:30px;width:40%;float:left;"><h3>签到情况</h3><table style="width:100%;" id="singIn"></table></div>

再写一个操作js,如下:

$(function(){
//查询签到、签退情况
loadTable(1);
//签到
$("#signIn").click(function(){
$("#checkType").val("1");
$("#signForm").submit();
});
//签退
$("#signOut").click(function(){
$("#checkType").val("2");
$("#signForm").submit();
});
});
//分页
function loadTable(checkType){
var columns = [
{"data": "inTime",header:"签到时间"},
{"data": "checkType",header:"签到"}
];
var params = {checkType:checkType};
//判断上传按钮权限-----------------------------
var buttons;
//buttons = {add:{fun:"upload",text:"上传文件"}};
//-----------------------------------------
var columnDefs ={
/* checkbox:true,
button:{
del:{//删除按钮
fun:"deleteFunction",//删除方法名称
text:"删除"
},
edit:{//修改按钮
fun:"editFunction",
text:"修改"
},
add:{
fun:"upload",
text:"上传文件"
}
},*/
button:buttons,
main:[{
"targets": 0,
render: function (a, b, c, d) {
return format(c.inTime,'yyyy-MM-dd HH:mm:ss');
}
},{
"targets":1//,
// render: function (a, b, c, d){
// return '<a style="color:#fff;" class="btn btn-primary btn-sm" href="${pageContext.request.contextPath}/jsp/scorm/updateScorm.jsp?id='+c.id+'&name='+c.name+'&intro='+encodeURI(encodeURI(c.intro))+'&timeopen='+c.timeopen+'&timeclose='+c.timeclose+'&maxgrade='+c.maxgrade+'&grademethod='+c.grademethod+'">修改</a>'
// +'&nbsp;&nbsp;&nbsp;<a style="color:#fff;" class="btn btn-primary btn-sm" href="javascript:if(confirm(\'你确定删除吗?\'))window.location.href=\'${pageContext.request.contextPath}/scorm/deleteScorm?id='+c.id+'\'">删除</a>';
// }
}] };
table = $("#singIn").table({ url:ctx+"/bankCheck/findSign",
params:params,
columns:columns,
columnDefs:columnDefs,
iDisplayLength:15
});
}
var format = function(time, format){
var t = new Date(time);
var tf = function(i){return (i < 10 ? '0' : '') + i};
return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function(a){
switch(a){
case 'yyyy':
return tf(t.getFullYear());
break;
case 'MM':
return tf(t.getMonth() + 1);
break;
case 'mm':
return tf(t.getMinutes());
break;
case 'dd':
return tf(t.getDate());
break;
case 'HH':
return tf(t.getHours());
break;
case 'ss':
return tf(t.getSeconds());
break;
}
})
}
  //if(valContent()){
   //         $.post(ctx+"/field/updateField",{fieldId:fieldId,fieldType:fieldType1,fieldName:fieldName1,orderNumber:orderNumber1,isDisable:isDisable1,remark:remark1},function(msg){
   //             if(msg.success){
   //                 table.reload(); --------------------table.reload()可用
   //                 $("#updateModal").modal('hide');
   //             }
   //         });
  //      }

后台controller如下:

/**
* 描述:查询签到、签退列表
* @param start
* @param length
* @param tempStr
* @return
*/
@RequestMapping("/findSign")
@ResponseBody
public GridReturn findSign(Integer start,Integer length,Integer checkType){
GridReturn gr = service.findSign(start, length,checkType);
return gr;
}

GridReturn如下:

package com.yunzainfo.common.pojo;

import java.util.List;

public class GridReturn {

    private int draw;//请求次数
private long recordsTotal;//总记录数
private long recordsFiltered;//过滤后记录数
private List<?> data; public GridReturn(int draw,long recordsTotal,long recordsFiltered,List<?> data){
this.data=data;
this.draw=draw;
this.recordsFiltered=recordsFiltered;
this.recordsTotal=recordsTotal;
} public int getDraw() {
return draw;
}
public void setDraw(int draw) {
this.draw = draw;
}
public long getRecordsTotal() {
return recordsTotal;
}
public void setRecordsTotal(long recordsTotal) {
this.recordsTotal = recordsTotal;
}
public long getRecordsFiltered() {
return recordsFiltered;
}
public void setRecordsFiltered(long recordsFiltered) {
this.recordsFiltered = recordsFiltered;
}
public List<?> getData() {
return data;
}
public void setData(List<?> data) {
this.data = data;
} }

service如下:

    @Override
public GridReturn findSign(Integer start, Integer length,Integer checkType) {
//获取userId
String userId = userDirectoryService.getCurrentUser().getId();
//获取siteId
String siteId = "";
try {
siteId = siteService.getSite(toolManager.getCurrentPlacement().getContext()).getId();
} catch (IdUnusedException e) {
e.printStackTrace();
}
Criteria criteria = new Criteria();
if(start!=null && length!=null){
criteria.setStart(start);
criteria.setLimit(length);
}
if(StringUtils.isNotBlank(siteId)){
criteria.put("siteId", siteId);
}
criteria.put("checkType", checkType);
criteria.put("userId", userId);
List<BankCheck> list = mapper.findList(criteria);
int total = mapper.getTotalCount(criteria);
GridReturn gridReturn = new GridReturn(criteria.getDraw(), total, total, list);
return gridReturn;
}

mapper如下:

<!-- 查询今天签到状态  -->
<select id="findList" parameterType="org.sakaiproject.util.Criteria"
resultType="com.yunzainfo.bank.module.bankCheck.pojo.BankCheck">
SELECT
check_id checkId,
in_time inTime,
out_time outTime,
user_id userId,
check_type checkType,
site_id siteId
FROM
bank_check
<where>
<if test="condition.checkId!=null">and check_id=#{condition.checkId}</if>
<if test="condition.inTime!=null">and in_time=#{condition.inTime}</if>
<if test="condition.outTime!=null">and out_time=#{condition.outTime}</if>
<if test="condition.userId!='' and condition.userId!=null">and user_id=#{condition.userId}</if>
<if test="condition.checkType!=null">and check_type=#{condition.checkType}</if>
<if test="condition.siteId!='' and condition.siteId!=null">and site_id=#{condition.siteId}</if>
</where>
order by in_time DESC,out_time DESC
<if test="limit!=0">limit #{start},#{limit}</if>
</select> <select id="getTotalCount" parameterType="org.sakaiproject.util.Criteria"
resultType="java.lang.Integer">
SELECT count(1)
FROM
bank_check
<where>
<if test="condition.checkId!=null">and check_id=#{condition.checkId}</if>
<if test="condition.inTime!=null">and in_time=#{condition.inTime}</if>
<if test="condition.outTime!=null">and out_time=#{condition.outTime},</if>
<if test="condition.userId!=''and condition.userId!=null">and user_id=#{condition.userId}</if>
<if test="condition.checkType!=null">and check_type=#{condition.checkType}</if>
<if test="condition.siteId!='' and condition.siteId!=null">and site_id=#{condition.siteId}</if>
</where>
</select>

最后结果如下:

jquery.dataTable分页的更多相关文章

  1. jquery datatable 获取当前分页的数据

    使用jquery datatable 遇到分页分别求和时,找了半天才找到获取当前分页数据的方法,以此总结 var table=$('#example').DataTable( { "pagi ...

  2. jquery datatable如何动态分页

    展开全部 一.分页 分页的基本思想是根据datatable的页码及每页显示的行数,将数据从数据库分段提出,然后再填充到表格中,以达到分页的效果. 这里需要用到datatable插件的几个属性: &qu ...

  3. 使用jQuery开发datatable分页表格插件

    当系统数据量很大时,前端的分页.异步获取方式就成了较好的解决方案.一直以来,我都希望使用自己开发的 jquery 插件做系统. 现在,学习了 jquery 插件开发之后,渐渐地也自己去尝试着开发一些简 ...

  4. 分享在MVC3.0中使用jQuery DataTable 插件

    前不久在网络上看见一个很不错的jQuery的DataTable表格插件.后来发现在MVC中使用该插件的文章并不多.本文将介绍在MVC3.0如何使用该插件.在介绍该插件之前先简单介绍一下,推荐该插件的原 ...

  5. JQuery Datatable用法

    原文出处:http://sgyyz.blog.51cto.com/5069360/1408251 目标: 使用jQuery Datatable构造数据列表,并且增加或者隐藏相应的列,已达到数据显示要求 ...

  6. jQuery Datatable 转载

    jQuery Datatable 实用简单实例 时间 2014-05-08 10:44:18  51CTO推荐博文 原文  http://sgyyz.blog.51cto.com/5069360/14 ...

  7. 使用jquery.datatable.js注意事项

    本文链接:https://blog.csdn.net/ylg01/article/details/76463908写在最前面的话,如果不是维护老项目或者在老项目上二次开发尽量不要用这个表格插件 为什么 ...

  8. jquery datatable使用简单示例

    目标: 使用 jQuery Datatable 构造数据列表,并且增加或者隐藏相应的列,已达到数据显示要求.同时, jQuery Datatable 强大的功能支持:排序,分页,搜索等. Query ...

  9. jquery dataTable汉化(插件形式)

    1.jquery dataTable.js 官网:http://datatables.net/ 中文:http://dt.thxopen.com/ 2.汉化提示信息(放到xx.js中,引入即可) 注: ...

随机推荐

  1. css定位之z-index问题分析

    新手先去看看   CSS z-index 属性    CSS z-index 属性的使用方法和层级树的概念 ---------------------------------------------- ...

  2. AngularJS API之bootstrap启动

    对于一般的使用者来说,AngularJS的ng-app都是手动绑定到某个dom元素.但是在一些应用中,这样就显得很不方便了. 绑定初始化 通过绑定来进行angular的初始化,会把js代码侵入到htm ...

  3. [转载]onkeydown、onkeypress、onkeyup、onblur、o

    转载链接: http://blog.sina.com.cn/s/blog_697b2dc101014ktb.html onkeydown:按下任何键(字母.数字.系统.tab等)都能触发,且对于字母不 ...

  4. 收到的电邮附件为Winmail.dat?

    以下信息来源于微软帮助中心:您收到电子邮件,其中包含一个 winmail.dat 的附件.电子邮件被人使用的 Microsoft Outlook 发送给您.该邮件的格式是丰富文本格式 (RTF). 原 ...

  5. ASP数据库操作方法

    首先,必须要使用打开数据库方法: <% dim objconn,objconnstr set objconn=server.createobject("adodb.connection ...

  6. nyoj 44 子串和 简单动态规划

    子串和 时间限制:5000 ms  |  内存限制:65535 KB 难度:3   描述 给定一整型数列{a1,a2...,an},找出连续非空子串{ax,ax+1,...,ay},使得该子序列的和最 ...

  7. su root 和su - root 的区别

    su - root  is   the same as su - just like login as root, then the shell is login shell,which mean i ...

  8. POJ 2054 Color a Tree

    贪心....                    Color a Tree Time Limit: 1000MS   Memory Limit: 30000K Total Submissions:  ...

  9. POJ 1905 Expanding Rods

                           Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1 ...

  10. Stm32 debug停留在"BKPT 0xAB"或者"SWI 0xAB"的解决办法。

    一..背景: 曾经在工作中接触过STM32一段时间,但没有深入的去学习,只是用前辈搭建好的模型来实现一些功能罢了,俗话说的好,大树底下好乘凉,开发确实轻松了,可是不深究点,又觉着心里不踏实,然而也一直 ...