javascript - 具有列搜索的 DataTable 不可折叠
问题描述
我正在使用来自:https : //datatables.net/ 的数据表我的数据表有列搜索,所以当我调整窗口大小时,我的列搜索字段不会折叠,它们会消失。
如果没有列搜索,它可以正常工作,但是当我添加列搜索代码时,我遇到了响应问题。
我的 HTML 文件:
<div class="table-responsive">
<table class="table table-bordered collapsed table-hover" id="wo-list">
<thead class="thead-light">
<tr>
<th class="font-weight-bold">#</th>
<th class="font-weight-bold">Created</th>
<th class="font-weight-bold">Scheduled</th>
<th class="font-weight-bold">Status</th>
<th class="font-weight-bold">Tech/Schedule</th>
<th class="font-weight-bold">Property</th>
<th class="font-weight-bold">Address</th>
<th class="font-weight-bold">Caller</th>
<th class="font-weight-bold">Phone</th>
<th class="font-weight-bold">Unit</th>
<th class="font-weight-bold">Call Reason</th>
<th class="font-weight-bold">Bill Est</th>
<th class="font-weight-bold">PO</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
我的脚本文件:
$(document).ready(function() {
$('#wo-list thead tr').clone(true).addClass('filters').appendTo(
'#wo-list thead' );
var table = $('#wo-list').DataTable({
responsive: true,
lengthMenu: [5, 10, 25, 50],
// deferLoading: 57,
orderCellsTop: true,
fixedHeader: true,
pageLength: 50,
ordering: false,
processing: true,
serverSide: true,
searching: true,
ajax: {
url: "{{ route('workorders.listing') }}",
type: 'GET',
data: function (d) {
d.wostatus = $('.wo_status').val();
d.schd_status = $('.schd_status').val();
d.created_date_range = $('.created_date').val();
d.technician = $('.wo_technician').val();
},
},
columns: [
{
data: 'workorder_id',
name: 'vt_workorders.workorder_id'
},
{
data: 'created_at',
name: 'vt_workorders.created_at',
width: 100
},
{
data: 'scheduled_status',
name: 'vt_workorders.scheduled_status'
},
{
data: 'status',
name: 'vt_workorders.status'
},
{
data: 'tech_name',
name: 'vt_properties.property_name',
searchable : false,
width: 180
},
{
data: 'property_name',
name: 'vt_properties.property_name'
},
{
data: 'address',
name: 'vt_properties.address'
},
{
data: 'caller',
name: 'vt_workorders.caller'
},
{
data: 'call_phone',
name: 'vt_workorders.call_phone'
},
{
data: 'unit_name',
name: 'vt_units.unit_name'
},
{
data: 'call_reason',
name: 'vt_workorders.call_reason'
},
// {
// data: 'revisions',
// name: 'revisions',
// searchable : false,
// width: 180,
// },
{
data: 'estimate_bill',
name: 'vt_workorders.estimate_bill',
},
{
data: 'PO',
name: 'PO',
// responsivePriority: -1
},
],
order: [
[0, 'desc']
]
});
});
});
解决方案
推荐阅读
- javascript - 我可以在 javascript 的选择列表上使用 onblur 吗?
- c++ - GCC:ld.exe 找不到文件
- sql - CASE 语句中关于 WHEN 的 GROUP BY 问题
- regex - 正则表达式:在文本中查找标记的字符串
- batch-file - 在 VsCode 中的按键上执行 bat 文件
- c++ - 在类型已知的情况下尝试跳过 vtable 和内联调用
- c++ - 使用 boost 元解析字符串解析包含的文件
- java - 是否可以使用 Java Google Sheets API 获取最后修改日期>特定日期的行
- docker - 使用 Linux grep 检查 docker-compose 服务是否健康
- c - 为什么 sscanf() 不在这里扫描?