我有一个 vue-good-table,我想在其中稍微限制列并制作一些复合列,这些列由行的多个属性组成。现在的问题是,filterFn 采用列名来填充方法的数据参数。所以我只能过滤我决定用作列名的那个。有没有办法像在 sortFn 中一样向 filterFn 提供整行对象?
模板:
<template v-if="props.column.field === 'flags'">
<div v-if="props.row.isGlobal">Global</div>
<div v-if="props.row.isMobile">Mobile</div>
</template>
列定义(我想显示设置了 Global 或 Mobile 标志的所有行):
{
label: 'Flags',
field: 'flags',
sortable: false,
filterOptions: {
enabled: true,
filterDropdownItems: ['Global', 'Mobile'],
filterFn: this.flagFilter,
},
},
功能(未定义不工作data
):
public flagFilter(data, filterString) {
if ('Global' === filterString) {
return data.isGlobal;
} else if ('Mobile' === filterString) {
return data.isMobile;
}
return true;
}