YADCF range_number-是否可以向/从范围添加预设选择列表?

时间:2018-09-06 14:25:45

标签: yadcf

我想向/从range_number字段中添加选择列表,以便用户可以从设置金额中选择设置范围。

1 个答案:

答案 0 :(得分:0)

最好的选择是使用自定义功能过滤filter_type: 'custom_func'

see showcase, first column,代码示例,所有内容都可以在该页面上找到

{
    column_number: 0,
    filter_type: 'custom_func',
    custom_func: myCustomFilterFunction,

...

(可能)自定义功能实现

function myCustomFilterFunction(filterVal, columnVal) {
    var found;
    if (columnVal === '') {
        return true;
    }
    switch (filterVal) {
    case 'happy':
        found = columnVal.search(/:-\]|:\)|Happy|JOY|:D/g);
        break;
    case 'sad':
        found = columnVal.search(/:\(|Sad|:'\(/g);
        break;
    case 'angry':
        found = columnVal.search(/!!!|Arr\.\.\./g);
        break;
    case 'lucky':
        found = columnVal.search(/777|Bingo/g);
        break;
    case 'january':
        found = columnVal.search(/01|Jan/g);
        break;
    default:
        found = 1;
        break;
    }

    if (found !== -1) {
        return true;
    }
    return false;
}