1

This might be more DataTables related than specifically YADCF but I'm asking it here as an obvious enhancement if the feature doesn't exist.

I have a column/s which can contain multiple value 'tags', similar to the YADCF examples. The filters to allow filtering by these tags generate correctly.

JSFiddle here https://jsfiddle.net/wallacio/622704ep/6/

See columns titled Area and Rig (excuse the horrific colours...!)

If I wish to see only the events in South, I need to use filter_match_mode: "exact" (to exclude those in South West, South East etc)

There is an event (8th down in unfiltered view) which contains tags "South" and "South East" Event containing South and South East tags

When the filtering for "South", this event does not appear, presumably because the exact filter is matching against the contents of the cell as a whole and not against each discrete HTML element within it.

I could change filter_match_mode to "contains" but this would result in events which are tagged "South East" etc appearing, which is undesirable.

I've had a trawl through the source and can see that this is taken into account when generating the filter options, but apparently not when filtering, which is why I wonder if it's a limitation caused by how DataTables filters are implemented.

Wallace
  • 111
  • 5

1 Answers1

1

You can use the filter_type: 'custom_func', and write your own filtering logic for that specific column

column_number: 0,
filter_type: 'custom_func',
custom_func: myCustomFilterFunction,
data: ['one', 'two', 'three']

where myCustomFilterFunction looks something like

function myCustomFilterFunction(filterVal, columnVal) {
        var found = false;
        if (columnVal === '') {
            return true;
        }
        switch (filterVal) {
        case 'one':
            found = //some logic goes here
            break;
        case 'two':
            found = //some logic goes here
            break;
        case 'three':
            found = //some logic goes here
            break;
        default:
            found = false;
            break;
        }

        if (found) {
            return true;
        }
        return false;
}
Daniel
  • 36,833
  • 10
  • 119
  • 200