将自己工作时的一些用过的东西保存或者整理下来,哈哈
1、去datatables的官网下载所需要的文件
附上链接:(http://www.datatables.club/)
2、将下载的压缩包解压放到自己的项目中,因为我使用的是tp5,这个个人是有差别的,在需要的页面引入css文件和js文件
<link rel="stylesheet" type="text/css" href="__STATIC__/business/lib/datatables/1.10.0/jquery.dataTables.min.css">
<script type="text/javascript" src="__STATIC__/business/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
3、就是在table上使用这个分页了,直接上代码吧,这是我写的一个小的例子,在实际中自己灵活应用哈
页面部分
<table id="table1">
<tr>
<th>订单编号</th>
<th>时间</th>
<th>操作</th>
</tr>
{if $orders}
{volist name="orders" id="order"}
<tr>
<th>{$order.order_number}</th>
<th>{$order.created_time}</th>
<th>详情</th>
</tr>
{/volist}
{/if}
</table>
js部分
$(function () {
$('#table1').dataTable({
searching: false, //去掉了datatables原始样式右上角的搜索框
bLengthChange: false,//去掉了datatables原始样式左上角的显示多少条的框
"lengthMenu": [30],//一页显示30条
"bStateSave":true,//刷新当前页面,table依然还是显示当前页
"order": [[2, "desc"]]//按照表格的第二行降序排列
});
});
第一次将自己的一些东西整理下来,再接再厉,哈哈