基于jquery實(shí)現(xiàn)表格無(wú)刷新分頁(yè)
本文實(shí)例講解了基于jquery實(shí)現(xiàn)表格無(wú)刷新分頁(yè)功能,分享給大家供大家參考,具體內(nèi)容如下
效果圖:

具體代碼:
<html>
<head>
<title>面向?qū)ο蟮臒o(wú)刷新表格分頁(yè)</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<link rel="stylesheet" href="css/king-table.css"/>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/king-table.js"></script>
</head>
<body>
<table id="cs_table" class="data-table"></table>
<br/>
<table id="cs_table2" class="data-table"></table>
<script type="text/javascript">
var data = [];
for(var i=0;i<103;i++){
data[i] = {id:i+1,name:"jason"+(i+1),gender:"男",age:i+1,address:"成都"};
}
var cs = new table({
"tableId":"cs_table", //必須 表格id
"headers":["序號(hào)","姓名","性別","年齡","地址"], //必須 thead表頭
"data":data, //必須 tbody 數(shù)據(jù)展示
"displayNum": 10, //必須 默認(rèn) 10 每頁(yè)顯示行數(shù)
"groupDataNum":5, //可選 默認(rèn) 10 組數(shù)
"display_tfoot":true, // true/false 是否顯示tfoot --- 默認(rèn)false
"bindContentTr":function(){ //可選 給tbody 每行綁定事件回調(diào)
this.tableObj.find("tbody").on("click",'tr',function(e){
return false;
var tr_index = $(this).data("tr_index"); // tr行號(hào) 從0開(kāi)始
var data_index = $(this).data("data_index"); //數(shù)據(jù)行號(hào) 從0開(kāi)始
})
},
sort:true, // 點(diǎn)擊表頭是否排序 true/false --- 默認(rèn)false
sortContent:[
{
index:0,//表頭序號(hào)
compareCallBack:function(a,b){ //排序比較的回調(diào)函數(shù)
var a=parseInt(a.id,10);
var b=parseInt(b.id,10);
if(a < b)
return -1;
else if(a == b)
return 0;
else
return 1;
}
},
{
index:3,//表頭序號(hào)
compareCallBack:function(a,b){ //排序比較的回調(diào)函數(shù)
var a=parseInt(a.age,10);
var b=parseInt(b.age,10);
if(a < b)
return -1;
else if(a == b)
return 0;
else
return 1;
}
}
],
specialRows:[
{
row:4,
cssText:{
"color":"#FFCF17"
}
}
],
search:true // 默認(rèn)為false 沒(méi)有搜索
});
</script>
</body>
</html>
html,body{margin: 0;padding:0}
a:focus {outline: none;}
h3.head_title {border-bottom: 1px solid #d5ddeb;color: #1c7493;display: block;font-size: 14px;height: 30px;line-height: 30px;margin-bottom: 10px;}
/* 通用表格顯示 */
table, th, td {font: 12px Arial,Helvetica,sans-serif,'宋體';margin: 0;padding: 0}
table{border-spacing: 0;border-collapse: collapse;empty-cells: show}
.data-table {width: 100%;border-style: none;background-color: #fff;/*margin-bottom: 20px;*/text-align: left;}
.data-table th, .data-table td { padding: 5px;line-height: 30px}
.data-table thead th {background-color: #eee;margin: 0;text-align: left;border-top: 1px solid #cfcfcf;border-bottom: 1px solid #cfcfcf;font-weight: 500}
.data-table tbody td {background-color: #fff;border-bottom: 1px dotted #ddd;table-layout:fixed;word-break:break-all;border-collapse:collapse;font-weight: 400}
.data-table tbody tr.evenrow td {background-color: #f4f4f4;}
.data-table tfoot td {background-color: #fafafa;text-align: right;border-bottom: 1px solid #cfcfcf;}
/*表格分頁(yè)列表*/
.data-table td.paging a {border: 1px solid #eee; color: #444; margin: 4px; padding: 2px 7px; text-decoration: none; text-align:center;}
/*表格分頁(yè)當(dāng)前頁(yè)*/
.data-table td.paging a.current {background: #eee; border: 1px solid #CFCFCF; color: #444; font-weight: bold;}
.data-table td.paging input{border:1px solid #4D90BB;font-family:Arial,sans-serif,Tahoma; font-size:12px; padding:0 5px;outline: none}
.data-table td.paging .search-txt{height:30px;line-height:30px;width: 100px }
.data-table td.paging .search-btn{height: 32px;border-left:none;cursor: pointer;_filter:chroma(color=#000000);_border:none;}
/*表格排序*/
.data-table thead th.bg{background:#eee url("../images/bg.gif") right center no-repeat;cursor: pointer}
.data-table thead th.asc{background: url("../images/asc.gif") right center no-repeat;cursor: pointer}
.data-table thead th.desc{background: url("../images/desc.gif") right center no-repeat;cursor: pointer}
以上就是基于jquery實(shí)現(xiàn)表格無(wú)刷新分頁(yè)功能的詳細(xì)代碼,希望對(duì)大家的學(xué)習(xí)有所幫助。
- 基于Jquery實(shí)現(xiàn)表格動(dòng)態(tài)分頁(yè)實(shí)現(xiàn)代碼
- 基于jquery實(shí)現(xiàn)的表格分頁(yè)實(shí)現(xiàn)代碼
- JQuery頁(yè)面的表格數(shù)據(jù)的增加與分頁(yè)的實(shí)現(xiàn)
- jquery 表格分頁(yè)等操作實(shí)現(xiàn)代碼(pagedown,pageup)
- 擴(kuò)展jquery實(shí)現(xiàn)客戶端表格的分頁(yè)、排序功能代碼
- 基于jQuery實(shí)現(xiàn)的無(wú)刷新表格分頁(yè)實(shí)例
- jQuery給表格添加分頁(yè)效果
- 利用jQuery實(shí)現(xiàn)一個(gè)簡(jiǎn)單的表格上下翻頁(yè)效果
相關(guān)文章
jQuery代碼實(shí)現(xiàn)圖片墻自動(dòng)+手動(dòng)淡入淡出切換效果
在網(wǎng)頁(yè)上經(jīng)??梢钥吹接斜尘皥D片可以自動(dòng)淡入淡入切換的效果,非常漂亮,實(shí)用性也非常高,今天小編給大家分享基于jquery代碼實(shí)現(xiàn)圖片墻自動(dòng)+手動(dòng)淡入淡出切換效果,感興趣的朋友一起學(xué)習(xí)吧2016-05-05
jquery入門—編寫一個(gè)導(dǎo)航條(可伸縮)
編寫一個(gè)導(dǎo)航條,單擊標(biāo)題時(shí),可以伸縮導(dǎo)航條內(nèi)容,簡(jiǎn)化內(nèi)容或顯示更多內(nèi)容等等效果相當(dāng)不錯(cuò),感興趣的朋友可以了解下哦2013-01-01
jQuery實(shí)現(xiàn)鼠標(biāo)響應(yīng)式淘寶動(dòng)畫效果示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)鼠標(biāo)響應(yīng)式淘寶動(dòng)畫效果,涉及jQuery事件響應(yīng)及頁(yè)面元素屬性動(dòng)態(tài)操作相關(guān)使用技巧,需要的朋友可以參考下2018-02-02
jQuery中使用Ajax獲取JSON格式數(shù)據(jù)示例代碼
有時(shí)候我們需要讀取JSON格式的數(shù)據(jù)文件,在jQuery中可以使用Ajax或者 $.getJSON()方法實(shí)現(xiàn),下面有個(gè)不錯(cuò)的示例,需要的朋友可以參考下2013-11-11
基于Jquery插件Uploadify實(shí)現(xiàn)實(shí)時(shí)顯示進(jìn)度條上傳圖片
這篇文章主要介紹了基于Jquery插件Uploadify實(shí)現(xiàn)實(shí)時(shí)顯示進(jìn)度條上傳圖片的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05
使用jQuery UI庫(kù)開(kāi)發(fā)Web界面的簡(jiǎn)單入門指引
這篇文章主要介紹了使用jQuery UI庫(kù)開(kāi)發(fā)Web界面的簡(jiǎn)單入門指引,jQuery UI是一個(gè)基于jQuery的圖形組件庫(kù),需要的朋友可以參考下2016-04-04
jQuery源碼分析-05異步隊(duì)列 Deferred 使用介紹
異步隊(duì)列是一個(gè)鏈?zhǔn)綄?duì)象,增強(qiáng)對(duì)回調(diào)函數(shù)的管理和調(diào)用,用于處理異步任務(wù)2011-11-11

