如何删除使用 "OR" 比较器创建的复杂过滤器?

How do I remove complex filters created with the "OR" comparator?

如何使用 removeFilter 去除复杂的过滤器(如文档中的示例)?

http://tabulator.info/docs/4.7/filter#func-complex

下面的示例应用了一个过滤器,允许年龄大于 52 岁且(身高小于 142 岁或姓名为史蒂夫)的行通过

table.setFilter([
    {field:"age", type:">", value:52}, //filter by age greater than 52
    [
        {field:"height", type:"<", value:142}, //with a height of less than 142
        {field:"name", type:"=", value:"steve"}, //or a name of steve
    ]
]);

删除所有过滤器

如果您想删除所有过滤器,您可以调用 clearFilter 函数

table.clearFilter();

删除一个复杂的过滤器

目前无法直接删除复杂过滤器集中的一个过滤器。在这种情况下,最好的方法是使用 getFilters 函数来检索当前过滤器列表,然后从您想要的数组中拼接过滤器摆脱掉,然后重新设置过滤器。

例如,如果您想从上面的示例中删除“名称”过滤器:

var filters = table.getFilters();

filters[1].splice(1,1) //remove second filter from the `OR` section of the complex filter array

table.setFilters(filters);