gpt4 book ai didi

javascript - YADCF - 使用隐藏列进行过滤

转载 作者:太空宇宙 更新时间:2023-11-04 15:28:44 25 4
gpt4 key购买 nike

经历这个jsFiddle ,我想知道隐藏列的 YADCF 等效项,如标准 DataTables 的使用所示,启用隐藏列的过滤(DataTable 的目标似乎相当于 YADCF 的列号)。

下面是我想要隐藏第一列的表格的代码, 但仍然允许过滤。

$(document).ready(function() {
'use strict';
var foodTable = $('#foodTable').DataTable({
});
yadcf.init(foodTable, [{
column_number: 0,
filter_type: "select",
visible: "false"
},
{
column_number: 1,
filter_type: "select"
}
], {
cumulative_filtering: true,
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/yadcf/0.9.1/jquery.dataTables.yadcf.js"></script>
<table id="foodTable">
<thead>
<tr>
<th>Category</th>
<th>Type</th>
<th>Subtype</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr>
<td>Fruit</td>
<td>Apple</td>
<td>Fuji</td>
<td>Very sweet apple</td>
</tr>
<tr>
<td>Vegetable</td>
<td>Pumpkin</td>
<td>Butternut</td>
<td>Very fibrous pumpkin</td>
</tr>
</tbody>
</table>

最佳答案

您应该将隐藏列的过滤器放置在表格之外,为此您可以使用 filter_container_id (阅读文档)

例如

yadcf.init(oTable, [{
column_number: 0,
filter_container_id: "myId",
column_data_type: "html",
filter_type: "multi_select"
},{
column_number: 1,
filter_type: "multi_select"
}], "footer");

See working jsfiddle

<div id="myId">
</div>

至于cumulative_filtering,您应该使用更新版本的 yadcf(请参阅更改日志)

关于javascript - YADCF - 使用隐藏列进行过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44995387/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com