成人精品一区二区三区中文字幕-成人精品一区二区三区-成人精品一级毛片-成人精品亚洲-日本在线视频一区二区-日本在线视频免费

導(dǎo)航首頁(yè) ? 技術(shù)教程 ? jQuery.datatables.js插件用法及api實(shí)例詳解
全站頭部文字 我要出現(xiàn)在這里
jQuery.datatables.js插件用法及api實(shí)例詳解 689 2024-02-14   

1、DataTables的默認(rèn)配置

$(document).ready(function() {
$(‘#example').dataTable();
} );

示例:http://www.guoxk.com/html/DataTables/Zero-configuration.html

2、DataTables的一些基礎(chǔ)屬性配置

“bPaginate”: true, //翻頁(yè)功能
“bLengthChange”: true, //改變每頁(yè)顯示數(shù)據(jù)數(shù)量
“bFilter”: true, //過(guò)濾功能
“bSort”: false, //排序功能
“bInfo”: true,//頁(yè)腳信息
“bAutoWidth”: true//自動(dòng)寬度

查看圖片

示例:http://www.guoxk.com/html/DataTables/Feature-enablement.html

3、數(shù)據(jù)排序

$(document).ready(function() {
$(‘#example').dataTable( {
“aaSorting”: [
[ 4, "desc" ]
]
} );
} );

從第0列開(kāi)始,以第4列倒序排列

示例:http://www.guoxk.com/html/DataTables/Sorting-data.html

4、多列排序

示例:http://www.guoxk.com/html/DataTables/Multi-column-sorting.html

5、隱藏某些列

$(document).ready(function() {
$(‘#example').dataTable( {
“aoColumnDefs”: [
{ "bSearchable": false, "bVisible": false, "aTargets": [ 2 ] },
{ “bVisible”: false, “aTargets”: [ 3 ] }
] } );
} );

示例:http://www.guoxk.com/html/DataTables/Hidden-columns.html

6、改變頁(yè)面上元素的位置

$(document).ready(function() {
$(‘#example').dataTable( {
“sDom”: ‘<”top”fli>rt<”bottom”p><”clear”>'
} );
} );
//l- 每頁(yè)顯示數(shù)量
//f ? 過(guò)濾輸入
//t ? 表單Table
//i ? 信息
//p ? 翻頁(yè)
//r ? pRocessing
//< and > ? div elements
//<”class” and > ? div with a class
//Examples: <”wrapper”flipt>, <lf<t>ip>

示例:http://www.guoxk.com/html/DataTables/DOM-positioning.html

7、狀態(tài)保存,使用了翻頁(yè)或者改變了每頁(yè)顯示數(shù)據(jù)數(shù)量,會(huì)保存在cookie中,下回訪問(wèn)時(shí)會(huì)顯示上一次關(guān)閉頁(yè)面時(shí)的內(nèi)容。

$(document).ready(function() {
$(‘#example').dataTable( {
“bStateSave”: true
} );
} );

示例:http://www.guoxk.com/html/DataTables/State-saving.html

8、顯示數(shù)字的翻頁(yè)樣式

$(document).ready(function() {
$(‘#example').dataTable( {
“sPaginationType”: “full_numbers”
} );
} );

示例:http://www.guoxk.com/html/DataTables/Alternative-pagination-styles.html

9、水平限制寬度

$(document).ready(function() {
$(‘#example').dataTable( {
“sScrollX”: “100%”,
“sScrollXInner”: “110%”,
“bScrollCollapse”: true
} );
} );

示例:http://www.guoxk.com/html/DataTables/Horizontal.html

10、垂直限制高度

示例:http://www.guoxk.com/html/DataTables/Vertical.html

11、水平和垂直兩個(gè)方向共同限制

示例:http://www.guoxk.com/html/DataTables/HorizontalVerticalBoth.html

12、改變語(yǔ)言

$(document).ready(function() {
$(‘#example').dataTable( {
“oLanguage”: {
“sLengthMenu”: “每頁(yè)顯示 _MENU_ 條記錄”,
“sZeroRecords”: “抱歉, 沒(méi)有找到”,
“sInfo”: “從 _START_ 到 _END_ /共 _TOTAL_ 條數(shù)據(jù)”,
“sInfoEmpty”: “沒(méi)有數(shù)據(jù)”,
“sInfoFiltered”: “(從 _MAX_ 條數(shù)據(jù)中檢索)”,
“oPaginate”: {
“sFirst”: “首頁(yè)”,
“sPrevious”: “前一頁(yè)”,
“sNext”: “后一頁(yè)”,
“sLast”: “尾頁(yè)”
},
“sZeroRecords”: “沒(méi)有檢索到數(shù)據(jù)”,
“sProcessing”: “<img src='http://www.gimoo.net/t/1811/5bf91bfa78829.html'" /loading.gif' />”
}
} );
} );

示例:http://www.guoxk.com/html/DataTables/Change-language-information.html

13、click事件

示例:http://www.guoxk.com/html/DataTables/event-click.html

14/配合使用tooltip插件

示例:http://www.guoxk.com/html/DataTables/tooltip.html

15、定義每頁(yè)顯示數(shù)據(jù)數(shù)量

$(document).ready(function() {
$(‘#example').dataTable( {
“aLengthMenu”: [[10, 25, 50, -1], [10, 25, 50, "All"]]
} );
} );

示例:http://www.guoxk.com/html/DataTables/length_menu.html

16、row callback

示例:http://www.guoxk.com/html/DataTables/RowCallback.html

最后一列的值如果為“A”則加粗顯示

17、排序控制

$(document).ready(function() {
$(‘#example').dataTable( {
“aoColumns”: [
null,
{ "asSorting": [ "asc" ] },
{ “asSorting”: [ "desc", "asc", "asc" ] },
{ “asSorting”: [ ] },
{ “asSorting”: [ ] }
]
} );
} );

示例:http://www.guoxk.com/html/DataTables/sort.html

說(shuō)明:第一列點(diǎn)擊按默認(rèn)情況排序,第二列點(diǎn)擊已順序排列,第三列點(diǎn)擊一次倒序,二三次順序,第四五列點(diǎn)擊不實(shí)現(xiàn)排序

18、從配置文件中讀取語(yǔ)言包

$(document).ready(function() {
$(‘#example').dataTable( {
“oLanguage”: {
“sUrl”: “cn.txt”
}
} );
} );

19、是用ajax源

$(document).ready(function() {
$(‘#example').dataTable( {
“bProcessing”: true,
“sAjaxSource”: ‘./arrays.txt'
} );
} );

示例:http://www.guoxk.com/html/DataTables/ajax.html

20、使用ajax,在服務(wù)器端整理數(shù)據(jù)

$(document).ready(function() {
$(‘#example').dataTable( {
“bProcessing”: true,
“bServerSide”: true,
“sPaginationType”: “full_numbers”,
“sAjaxSource”: “./server_processing.php”,
/*如果加上下面這段內(nèi)容,則使用post方式傳遞數(shù)據(jù)
“fnServerData”: function ( sSource, aoData, fnCallback ) {
$.ajax( {
“dataType”: ‘json',
“type”: “POST”,
“url”: sSource,
“data”: aoData,
“success”: fnCallback
} );
}*/
“oLanguage”: {
“sUrl”: “cn.txt”
},
“aoColumns”: [
{ "sName": "platform" },
{ "sName": "version" },
{ "sName": "engine" },
{ "sName": "browser" },
{ "sName": "grade" }
]//$_GET['sColumns']將接收到aoColumns傳遞數(shù)據(jù)
} );
} );

示例:http://www.guoxk.com/html/DataTables/ajax-serverSide.html

21、為每行加載id和class

服務(wù)器端返回?cái)?shù)據(jù)的格式:

{
“DT_RowId”: “row_8″,
“DT_RowClass”: “gradeA”,
“0″: “Gecko”,
“1″: “Firefox 1.5″,
“2″: “Win 98+ / OSX.2+”,
“3″: “1.8″,
“4″: “A”
},

示例:http://www.guoxk.com/html/DataTables/add_id_class.html

22、為每行顯示細(xì)節(jié),點(diǎn)擊行開(kāi)頭的“+”號(hào)展開(kāi)細(xì)節(jié)顯示

示例:http://www.guoxk.com/html/DataTables/with-row-information.html

查看圖片

23、選擇多行

示例:http://www.guoxk.com/html/DataTables/selectRows.html

22、集成jQuery插件jEditable

示例:http://www.guoxk.com/html/DataTables/jEditable-integration.html

更過(guò)參考:

要注意的是,要被dataTable處理的table對(duì)象,必須有thead與tbody,而且,結(jié)構(gòu)要規(guī)整(數(shù)據(jù)不一定要完整),這樣才能正確處理。

以下是在進(jìn)行dataTable綁定處理時(shí)候可以附加的參數(shù):

查看圖片

查看圖片

查看圖片

查看圖片

以上所述是小編給大家介紹的jQuery.datatables.js插件用法及api實(shí)例詳解,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)綠夏網(wǎng)網(wǎng)站的支持!



主站蜘蛛池模板: 日韩大胆视频| 高达w| 周秀娜三级大尺度视频| 抖音官方| 李英恩| 薛昊婧演过的电视剧| 《杨贵妃淫史》三级| 如如123| 刘德华歌| 今日航班一览表| porn4k| 电视剧零下三十八度手机免费观看| 我爱你在线观看| 疑云密布 电影| 贾冰又出新的喜剧电影| 肚兜电影| 谭咏麟个人资料简介| 向团组织靠拢的打算| 免费完整队列训练教案| 女同视频在线| 燃烧的岁月| 追捕演员表| 经典常谈周易第二读书笔记 | 高达uce| 奔跑吧第13季| 黑色罪案电影免费观看| 楚门的世界演员表| 祈今朝电视剧免费观看影视大全| 王春晖| 黄色网址视频在线播放| 42个奥特曼大全图| 超英| 戴氏家族目前最大官| 女同性恋视频网站| 荆棘花| 湖北经视频道| 伦理电影在线看| 强者世界| 三年电影免费完整版| 可爱美女跳舞蹈视频| 妻子的秘密免费观看全集|

!!!站長(zhǎng)長(zhǎng)期在線接!??!

網(wǎng)站、小程序:定制開(kāi)發(fā)/二次開(kāi)發(fā)/仿制開(kāi)發(fā)等

各種疑難雜癥解決/定制接口/定制采集等

站長(zhǎng)微信:lxwl520520

站長(zhǎng)QQ:1737366103