I'm using DataTables with yadcf. I'd like to implement tag selection. I found the example here: https://stackoverflow.com/a/35254351/2604492
But it uses filter_match_mode=contains
(the default), which means that if there are eg two tags, php
and not-php
, choosing php
will match not-php
too as the former is contained in the latter.
Example: https://jsfiddle.net/o7hv6qpy/
With filter_match_mode=exact
it just stops working.
Any solution?
One way to achieve it is to use the custom_func
like shown below.
You can put your exact
logic into the custom_func
implementation
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;
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.