在浏览这个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>
发布于 2017-07-10 08:09:34
您应该将隐藏列的筛选器放在表的外面,为此您可以使用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");见工作小提琴
<div id="myId">
</div>至于cumulative_filtering,您应该使用较新版本的yadcf (请参阅更改日志)。
https://stackoverflow.com/questions/44995387
复制相似问题