[英]Tag selection in table (rendered_html with filter_match_mode=exact)
我将 DataTables 与 yadcf 一起使用。 我想实现标签选择。 我在这里找到了这个例子: https://stackoverflow.com/a/35254351/2604492
但是它使用filter_match_mode=contains
(默认),这意味着如果有两个标签,例如php
和not-php
,选择php
也会匹配not-php
,因为前者包含在后者中。
示例: https://jsfiddle.net/o7hv6qpy/
使用filter_match_mode=exact
它只是停止工作。
有什么解决办法吗?
实现它的一种方法是使用custom_func
,如下所示。
您可以将您的exact
逻辑放入custom_func
实现中
yadcf.init(table, [
{
column_number : 1,
column_data_type: "rendered_html",
html_data_type: "text",
filter_default_label: "Select tag",
text_data_delimiter: ',',
filter_type: 'custom_func',
custom_func: myCustomFilterFunction
}
]);
function myCustomFilterFunction(filterVal, columnVal) {
const items = columnVal.split(',');
return items.some(function(arrVal) {
return filterVal === arrVal;
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.