在页脚中使用过滤器进行列搜索 - 未显示页脚过滤器 - Laravel Datatables Yajrabox
Column search with filter in footer - footer filter not showing - Laravel Datatables Yajrabox
我正在使用 Yajrabox Laravel datatables 来显示数据。很简单,只要尝试教程中给出的内容即可。但是,在 table 的页脚中输入的文本框没有显示出来。
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();
});
});
}
});
数据table 按预期显示,列和数据、排序和搜索功能在 table 之上。
但是,页脚不显示过滤框,而过滤框应该如示例中所示显示。
我不确定我错过了什么。如果有人能指出我正确的方向,那将会很有帮助。
感谢@Gyrocode 指出关于 tfoot 的问题。我的 table 没有元素。我必须添加它,然后页脚开始与列过滤器一起显示。
此处为可能遇到类似问题的任何人提供了示例代码。
<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>
我正在使用 Yajrabox Laravel datatables 来显示数据。很简单,只要尝试教程中给出的内容即可。但是,在 table 的页脚中输入的文本框没有显示出来。
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();
});
});
}
});
数据table 按预期显示,列和数据、排序和搜索功能在 table 之上。
但是,页脚不显示过滤框,而过滤框应该如示例中所示显示。
我不确定我错过了什么。如果有人能指出我正确的方向,那将会很有帮助。
感谢@Gyrocode 指出关于 tfoot 的问题。我的 table 没有元素。我必须添加它,然后页脚开始与列过滤器一起显示。
此处为可能遇到类似问题的任何人提供了示例代码。
<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>