0

我正在尝试使用 DataTables 的输入插件进行分页。我已经加载了所有三个 jar 文件 - jQuery1.11.1、dataTables1.10 和 input.js。但我仍然得到

TypeError: $.fn.dataTableExt is undefined 

TypeError: plugin is undefined

错误。

我必须包括任何其他罐子吗?在一些旧帖子中,我看到 plugin.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"
});
4

2 回答 2

1

从dataTable 1.10开始,他们改变了分页结构。现在他们使用“paging”(布尔)、“pagingType”(字符串)属性,而且似乎他们也改变了分页插件结构。结果,每个分页插件都无法在 1.10 上运行。您可以使用数据表 1.9。

新的分页选项: http ://datatables.net/reference/option/pagingType

分页插件页面正在建设中: http: //datatables.net/manual/plug-ins/paging

它们提供 full、simple、full_numbers 和 simple_numbers 作为默认选项。如果你想使用输入分页,你可以在他们的 github上下载 dataTable 1.9或者尝试像他们在升级部分提供的那样制作自己的向后兼容逻辑。

$(document).ready(function() {
    $('#example').dataTable( {
      "pagingType": "full_numbers"
    } );
} );
于 2015-02-03T10:28:52.110 回答
-1

文件

<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

使用上述内容进行分页。如果您仍然遇到问题,请从上面的链接添加文件并重试。

于 2015-02-06T11:24:48.713 回答