使用自定义函数填充数据
Populate data with custom function
如何将自定义过滤器选项和所有其他数据添加到自定义函数中?
下面是我的代码。我想要有“是”和“否”过滤器,但也想过滤列中的所有其他值。
{column_number: creator_index,
filter_type: 'custom_func',
custom_func: Creator_Filter_Function,
data: [
{value: 'yes', label: 'Yes'},
{value: 'no', label: 'No'},
],
filter_default_label: "All"
},
您应该为过滤器使用 append_data_to_table_data 选项
来自文档:
- append_data_to_table_data
Required: false
Type: string
Default value: undefined
Possible values: before / sorted
Description: Use 'before' to place your data array before the values that yadcf grabs from the table
use 'sorted' to place the data array sorted along with the values that yadcf grabs from the table
Note: 'sorted' option will have affect only if you data is an array of primitives (not objects)
因此最终您的代码将如下所示
{
append_data_to_table_data: 'before',
column_number: creator_index,
filter_type: 'custom_func',
custom_func: Creator_Filter_Function,
data: [
{value: 'yes', label: 'Yes'},
{value: 'no', label: 'No'},
],
filter_default_label: "All"
},
如何将自定义过滤器选项和所有其他数据添加到自定义函数中?
下面是我的代码。我想要有“是”和“否”过滤器,但也想过滤列中的所有其他值。
{column_number: creator_index,
filter_type: 'custom_func',
custom_func: Creator_Filter_Function,
data: [
{value: 'yes', label: 'Yes'},
{value: 'no', label: 'No'},
],
filter_default_label: "All"
},
您应该为过滤器使用 append_data_to_table_data 选项
来自文档:
- append_data_to_table_data Required: false Type: string Default value: undefined Possible values: before / sorted Description: Use 'before' to place your data array before the values that yadcf grabs from the table use 'sorted' to place the data array sorted along with the values that yadcf grabs from the table Note: 'sorted' option will have affect only if you data is an array of primitives (not objects)
因此最终您的代码将如下所示
{
append_data_to_table_data: 'before',
column_number: creator_index,
filter_type: 'custom_func',
custom_func: Creator_Filter_Function,
data: [
{value: 'yes', label: 'Yes'},
{value: 'no', label: 'No'},
],
filter_default_label: "All"
},