filter multiple values on one column

filter multiple values on one column

54696d2054696d20 Posts: 75Questions: 18Answers: 0

You'll see here:
http://live.datatables.net/yeqazuze/22

I'm filtering the ServiceID. My example, I'm searching just 2 values (could be more or less). In my mind I should only get lines that have both of those values, but that's not the case. You can test with this by searching "03100500 03010200". You'll see that it shows 6 rows and not 7.

Is there a way to change that? I have another column that will be the same. I'm thinking it doesn't like the "|" delimiter.

Thanks for the help

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hi @54696d20 ,

    It does if you treat it as a regular expressed - try (airi|ashton) as the search on this page here. If you want regex style without the |, you'll need to either have your own input element that instigates the search, or change the event handler on the standard search.

    Cheers,

    Colin

  • 54696d2054696d20 Posts: 75Questions: 18Answers: 0

    Hey @colin ,

    Thanks for the feedback. Unfortunately, your example is not going to work. I'm looking to match only people that have airi and ashton. Using your example, It returns two lines. I'm looking to return no lines, because there are no Column - Name with airi and ashton on the same line. My example should only return 6 lines, because there are only 6 lines that have both.

    Would you have another way to do this?

    Thanks again

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hey again,

    I may be being daft here, but that's what I'm seeing. The table originally shows 7 entries, I search for "03100500 03010200", and Bella is removed as she doesn't contain the second value, leaving just the 6 rows that contain both.

    If I'm missing something, could you give me steps to reproduce please.

    Cheers,

    Colin

  • 54696d2054696d20 Posts: 75Questions: 18Answers: 0

    Hey @colin ,

    I believe I figured out a solution. http://live.datatables.net/yeqazuze/24

    Look at the bottom of the JS file. I think you'll see what i"m talking about. It's like the difference between OR and AND

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    Answer ✓

    Ah, gotcha, it was being filtered already! Not my finest hour...

    As it's the default behaviour, you can make it a lot simpler with this:

    table.column(13).search(val.join(' ')).draw();
    

    C

  • 54696d2054696d20 Posts: 75Questions: 18Answers: 0

    @colin We all have those.. Thanks this worked.

This discussion has been closed.