Column filter multiple value

Column filter multiple value

lionellionellionellionel Posts: 21Questions: 4Answers: 0

Hello everyone,

I would like to have a column filter select which displays multiple option if a line contains values separated by a coma instead of only one value.

For example, if I have the column author with "Louis Durand,Jean Delatour", I would like to have two values in the select, "Louis Durand" and "Jean Delatour" and not "Louis Durand,Jean Delatour".

Moreover, I want to be able when I select Jean Delatour author to display all the lines where Jean Delatour is an author, whatever if he is the only one or not.

I create an jsfiddle in order to illustrate my example.
https://jsfiddle.net/margarette/xnr9mcjd/13/

Thank you in advance for you help,
Lionel

Replies

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    You would need to change the search() so it's not using a regex, and remove the "^" and "$". Then in this code,

                    column.data().unique().sort().each( function ( d, j ) {
                        select.append( '<option value="'+d+'">'+d+'</option>' )
                    } );
    

    use split() and all the results to the select,

    Colin

  • lionellionellionellionel Posts: 21Questions: 4Answers: 0

    Thank you for your answer Colin, it helped me a lot!

Sign In or Register to comment.