Including and excluding expression at once

Including and excluding expression at once

midzmidz Posts: 7Questions: 2Answers: 0

Hello,
I am trying to make datatable filter with two inputs in each th cell, where one input should work as usual - filter rows which contains entered expression and second input should exclude rows that contains this expression.

For example I have table which contains three rows - "Ford Mustang", "Ford Focus" and "Ford Mondeo". In first input I will write "Ford" and in second "Mustang". The datatable should show all Ford cars which are not Ford Mustang.

Is it possible with datatables?

Thank you for your help!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Two options:

    1. Use a regex with the column().search() method, or
    2. Use a custom search plug-in.

    Allan

  • midzmidz Posts: 7Questions: 2Answers: 0

    Hello Allan,
    thank you for your response. Can you please provide more information about the first option? How can i exclude for example expression "mustang"?

    Thank you very much!

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    This little example shows a regex being used to search for rows that do not contain "Ashton".

    Allan

  • midzmidz Posts: 7Questions: 2Answers: 0

    Thank you very much Allan.

This discussion has been closed.