我正在尝试使用数据表的输入插件进行分页。我已经加载了所有三个jar文件 - jQuery1.11.1,dataTables1.10和input.js。但我仍然得到
TypeError: $.fn.dataTableExt is undefined
和
TypeError: plugin is undefined
错误。
我必须包括任何其他罐子吗?在一些旧帖子中,我看到插件正在加载.jar但在 DataTables 插件页面本身中没有提到这个 JAR。
数据表初始化代码
var table = $jq11('#openCasesTable').dataTable({
"ajax": someUrl,
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [0, 6, 7] }
],
"columns": [
{
"data": null,
"render": function(data, type, row, meta) {
...
}
},
...
],
"deferRender": true,
"dom": 'l<"#removeButtonDiv.removeButton">rtip',
"filter": false,
"initComplete": function(settings, json) {
$('#removeButtonDiv').html('<input id="removeButton" type="button" value="Remove" style="float:right; height: 25px;" disabled />');
},
"lengthMenu": [ [20, 40, 60, 80, 100], [20, 40, 60, 80, 100] ],
"language": {
"emptyTable": "No data to list",
"infoFiltered": " "
},
"order": [[4, "desc"]],
"processing": true,
"drawCallback": function( settings ) {
$.each(selected, function(index, value){
$('#'+value).attr("checked", "checked");
});
},
"serverSide": true,
"sPaginationType": "input"
});
从数据表1.10开始,他们改变了分页结构。现在他们使用"分页"(布尔值),"分页类型"(字符串)属性,似乎他们也改变了分页插件结构。因此,每个分页插件在 1.10 上都不起作用。您可以使用数据表1.9。
新的分页选项:http://datatables.net/reference/option/pagingType
分页插件页面正在建设中:http://datatables.net/manual/plug-ins/paging
它们提供完整、简单、full_numbers和simple_numbers作为默认选项。如果你想使用输入分页,你可以在他们的github中下载dataTable 1.9,或者尝试制作自己的向后兼容性逻辑,就像他们在升级部分提供的那样。
$(document).ready(function() {
$('#example').dataTable( {
"pagingType": "full_numbers"
} );
} );
HTML 文件
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
JAVASCRIPT 文件
$(document).ready(function() {
$('#example').DataTable();
} );
包括下面的css以及格式化
../../media/css/jquery.dataTables.css
所有的东西,样本和示例都在下面,你可以下载它。
http://www.datatables.net/download/download
使用上述内容进行分页。如果您仍然遇到问题,请从上面的链接添加文件,然后重试。