Search code examples
javascripttabulator

Filtering doesn't work on a field constructed via a function


I have this column definition:

{ title:"User name", field:"whatever", formatter:fleetTableUserFormatter, width: '20%', headerFilter:true },

And then the fleetTableUserFormatter:

function fleetTableUserFormatter(cell){
    let data = cell.getData();
    if (data.user_first_name || data.user_last_name){
        return `${ data.user_first_name } ${ data.user_last_name } [${ data.user_number }]`;
    }
    return 'Undefined';
}

And the filtering just doesn't work, it does show up, but when entering valid data, it filters out everything.

I assume I should maybe create a function, and then headerFilter:myFunction but I can't google any information about what this function is supposed to return?


Solution

  • You cant filter on data created in a formatter.

    Formatters are visual only, the don't affect sorting or filtering.

    If you want to use sorting or filtering of a column of this sort then you need to use a Mutator to create the data.

    This will then be available for use in filtering and sorting