制表符/正则表达式过滤器不区分大小写?

问题描述 投票:0回答:2

看起来 Tabulator 的正则表达式过滤器区分大小写。有没有简单的方法让它不区分大小写?

regex filter tabulator
2个回答
2
投票

成功了:

column.headerFilterFunc = function customHeaderFilter(headerValue, rowValue, rowData, filterParams){                        
    return rowValue.match(new RegExp(headerValue, 'i')); 
};

0
投票

column.headerFilterFunc = function customHeaderFilter(headerValue, rowValue, rowData, filterParams){                        
        RegExp(headerValue, 'i').test(rowValue);
    };

//Column definition, need to set headerFilterFunc property:
 { title: "MyColumn", field: "fieldName", sorter: "string", headerFilter: true, headerFilterFunc: customHeaderFilter }

如果列包含任何空值,则主要答案会导致错误“无法读取 null 的属性(读取‘匹配’)”。应该使用 Robert M. Münch 对他的回答的评论来解决这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.