4

我正在使用 Yajrabox Laravel 数据表来显示数据。非常简单,只需尝试教程中给出的内容。但是,在表的页脚中输入的文本框没有显示出来。

https://datatables.yajrabox.com/eloquent/multi-filter-select

使用页面中的相同代码 - 源代码。

$('#users-table').DataTable({
    processing: true,
    serverSide: true,
    ajax: 'https://datatables.yajrabox.com/eloquent/multi-filter-select-data',
    columns: [
        {data: 'id', name: 'id'},
        {data: 'name', name: 'name'},
        {data: 'email', name: 'email'},
        {data: 'created_at', name: 'created_at'},
        {data: 'updated_at', name: 'updated_at'}
    ],
    initComplete: function () {
        this.api().columns().every(function () {
            var column = this;
            var input = document.createElement("input");
            $(input).appendTo($(column.footer()).empty())
            .on('change', function () {
                column.search($(this).val(), false, false, true).draw();
            });
        });
    }
});

数据表按预期显示,列和数据、排序和搜索功能位于表顶部。

但是,页脚不显示过滤器框,而过滤器框应该显示在示例中。

我不确定我错过了什么。如果有人能指出我正确的方向,那将很有帮助。

4

1 回答 1

8

感谢@Gyrocode 指出 tfoot。我的桌子没有元素。我必须添加它,然后页脚开始与列过滤器一起显示。

示例代码适用于可能遇到类似问题的任何人。

<table id="users-table" class="table table-condensed">
<thead>
    <tr>
        <th>Id</th>
        <th>Name</th>
        <th>Email</th>
        <th>Created At</th>
        <th>Updated At</th>
    </tr>
</thead>
<tfoot>
    <tr>
        <th>Id</th>
        <th>Name</th>
        <th>Email</th>
        <th>Created At</th>
        <th>Updated At</th>
    </tr>
</tfoot>

于 2018-12-29T04:19:56.587 回答