YADCF - 使用隐藏列进行过滤

YADCF - filtering using hidden columns

通过这个jsFiddle, I wanted to know the YADCF equivalent of hidden columns, as shown in use for the standard DataTables,启用从隐藏列中过滤(DataTable 的目标似乎等同于 YADCF 的列号)。

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

$(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>

您应该将隐藏列的过滤器放在 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(请参阅更改日志)