DataTables is a jQuery table plug-in. This is a highly flexible tool based on progressive enhancements that will add advanced interactive controls and support for any HTML form.
Usage:
First look at the following code:
1 2 3 4 5 6 7 8 9 | <title>DataTables example</title>
<style type= "text/css" title= "currentStyle" >
@import "../../media/css/demo_page.css" ;
@import "../../media/css/demo_table.css" ;
@import "../examples_support/themes/smoothness/jquery-ui-1.7.2.custom.css" ;
</style>
<script type= "text/javascript" language= "javascript" src= "../../media/js/jquery.js" ></script>
<script type= "text/javascript" language= "javascript" src= "../../media/js/jquery.dataTables.js" ></script>
<script type= "text/javascript" charset= "utf-8" >
|
Copy after login
Introduce js and css files into the above code. It can be copied in the demo. Pay attention to the path address.
Then let’s take a look at the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <script type= "text/javascript" charset= "utf-8" >
$(document).ready( function () {
$('#example').dataTable( {
"oLanguage" : {
"sUrl" : "/SSS/dataTables/de_DE.txt"
},
"bStateSave" : true,
"sPaginationType" : "full_numbers"
} );
} );
</script>
</head>
<body id= "dt_example" >
<p id= "container" align= "center" >
<h1>物品种类管理</h1>
<p id= "demo" >
<table cellpadding= "5" cellspacing= "0" border= "1" class = "display" id= "example" align= "center" >
<thead>
<tr>
<th>物品编号</th>
<th>物品名称</th>
<th>物品单位</th>
<th>编辑状态</th>
<th>随便</th>
</tr>
</thead>
<tr class = "gradeX" >
<td>Trident</td>
<td>Internet
Explorer 4.0</td>
<td>Win 95+</td>
<td class = "center" >4</td>
<td class = "center" >X</td>
</tr>
<tr class = "gradeC" >
<td>Trident</td>
<td>Internet
Explorer 5.0</td>
<td>Win 95+</td>
<td class = "center" >5</td>
<td class = "center" >C</td>
</tr>
<tr class = "gradeA" >
<td>Trident</td>
<td>Internet
Explorer 5.5</td>
<td>Win 95+</td>
<td class = "center" >5.5</td>
<td class = "center" >A</td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
</p>
</p>
|
Copy after login
The above will create the effect as shown in the picture, paging. Sort. etc.
Finally, let’s talk about each attribute (the main location to add)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
$(document).ready( function () {
oTable = $('#example').dataTable({
"bJQueryUI" : true,
"sPaginationType" : "full_numbers"
});
} );
|
Copy after login
The default language is English, of course it can be internationalized:
"sUrl": "/SSS/dataTables/de_DE.txt" Just add an internationalized file. The name can be anything as long as the path is correct. The content of the internationalization file I wrote is as follows, which can be directly copied to txt for use.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | {
"sProcessing" : "Bitte warten..." ,
"sLengthMenu" : "显示_MENU_条 " ,
"sZeroRecords" : "没有您要搜索的内容" ,
"sInfo" : "从_START_ 到 _END_ 条记录——总记录数为 _TOTAL_ 条" ,
"sInfoEmpty" : "记录数为0" ,
"sInfoFiltered" : "(全部记录数 _MAX_ 条)" ,
"sInfoPostFix" : "" ,
"sSearch" : "搜索" ,
"sUrl" : "" ,
"oPaginate" : {
"sFirst" : "第一页" ,
"sPrevious" : " 上一页 " ,
"sNext" : " 下一页 " ,
"sLast" : " 最后一页 "
}
}
|
Copy after login
The above is the detailed content of Introduction to jquery plug-in datatables attributes and detailed explanations of creating paging and sorting examples. For more information, please follow other related articles on the PHP Chinese website!