jQuery datatables使用 ( 前台页面实现分页 简单案例一 未完待续...)

10 篇文章 0 订阅
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>角色设置</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<%@ include file="../taglibs.jsp" %>

[color=red] <!--引入样式文件和脚本文件-->

<link href="${ctx}/css/common/style1.css" style="text/css" rel="stylesheet">
<link href="${ctx}/css/dataTables/demo_page.css" style="text/css" rel="stylesheet">
<link href="${ctx}/css/dataTables/demo_table_jui.css" style="text/css" rel="stylesheet">
<link href="${ctx}/css/dataTables/demo_table.css" style="text/css" rel="stylesheet">[/color] </head>

<script type="text/javascript" language="javascript" src="js/dataTables/jquery.js"></script>
<script type="text/javascript" language="javascript" src="js/dataTables/jquery.dataTables.js"></script>

[color=red]
<!--嵌入JS代码设置分页操作-->[/color]
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#example').dataTable({
//iDisplayLength:1,//设置每页显示数量
sPaginationType: "full_numbers",// 设置分页按钮
//bJQueryUI: true, //设置样式
bStateSave: true
//其他具体操作属性...
});
});

</script>

<body>

<!-- 显示区域 -->
<fieldset>
<legend>角色管理</legend>
<form class="feildset clearfix dataForm ">
<table class="gridtable" style="width:100%" id="[color=red]example[/color]">
[color=red] <thead>[/color] <tr>
<th width="5%" align="center"><input type="checkbox" οnclick="selectAll()" id="checkbox"/></th>
<th width="10%" align="center">用户名</th>
<th width="10%" align="center">真实姓名</th>
<th width="10%" align="center"> 密码</th>
<th width="5%" align="center"> 是否启用</th>
<th width="10%" align="center"> 电子邮箱</th>
<th width="10%" align="center"> 联系电话</th>
<th width="10%" align="center"> 手机号码</th>
<th width="10%" align="center"> 备注</th>

</tr>
[color=red]</thead>
<tbody>[/color] <c:forEach var="user" items="${userList}">
<tr>
<td align="center"><input type="checkbox" value="${user.userId}" name="userId"/></td>
<td align="center">${user.userName} </td>
<td align="center">${user.realName}</td>
<td align="center">${user.password}</td>
<td align="center">
<c:if test="${user.whetherStop==true}">是 </c:if>
<c:if test="${user.whetherStop==false}">否 </c:if>

</td>
<td align="center">${user.email }</td>
<td align="center">${user.telephone }</td>
<td align="center">${user.mobilephone }</td>
<td align="center">${user.remarks }</td>
</tr>
</c:forEach>
[color=red]</tbody>[/color]
</table>
</form>
</fieldset>
</body>
function selectAll(){
var interArr = document.getElementsByName("userId");

for ( var i = 0; i < interArr.length; i++) {
if (!interArr[i].checked) {
interArr[i].checked = true;
}
}
var checkbox=document.getElementById("checkbox");
if(!checkbox.checked){
for ( var i = 0; i < interArr.length; i++) {
interArr[i].checked = false;
}
}

}
</script>
</html>
注:必须写table的<tbody>和<thead>标签,红色区域是需要注意的地方
或参考:http://apps.hi.baidu.com/share/detail/44192495
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值