[英]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.