How to search for exact value in header search box

How to search for exact value in header search box

martin1223345martin1223345 Posts: 61Questions: 18Answers: 0

live.datatables.net/mowobugu/1/edit

I cant figgur out how to search for the exact value in the added header search code in above example.. Is there a way to make datatables search for the exact result? Atm when searching Anneke, the result is also showing Janneke. It should only show Anneke.

Answers

  • kthorngrenkthorngren Posts: 14,086Questions: 25Answers: 3,322
    edited October 17

    Use regex searching. See this example. The select input example uses regex searching. Change your search to use regex similar to the select example.

    Also you might want to use orderCellsTop to move the sorting events to the top row.

    Kevin

  • martin1223345martin1223345 Posts: 61Questions: 18Answers: 0

    Thanks for reacting. I did found examples like yours. But I dont understand how to implent the regex into the example in my link.. Please help

  • martin1223345martin1223345 Posts: 61Questions: 18Answers: 0

    See below example. It is just not working for me all the options I find. So please help how to make this work..

    live.datatables.net/mowobugu/1/edit

  • martin1223345martin1223345 Posts: 61Questions: 18Answers: 0

    When changing this.value to this.val it seems to work but than when empty it does nog reset..

  • kthorngrenkthorngren Posts: 14,086Questions: 25Answers: 3,322

    Your first example has this error:

    VM448:41 Uncaught TypeError: $(...).value is not a function

    You have this:

    .search("^" + $(this).value() + "$", true, false, true)
    

    Use $(this).val() instead of $(this).value(). Here is the updated example:
    http://live.datatables.net/mowobugu/3/edit

    Kevin

  • martin1223345martin1223345 Posts: 61Questions: 18Answers: 0

    Thanks. I noticed that as i posted in my first comment. But when removing the results the table is not
    refreshed to the original results. Any way to do this?

  • colincolin Posts: 12,877Questions: 0Answers: 2,198

    It just needs some logic to determine if there is a search string in place - see updated example here: http://live.datatables.net/mowobugu/4/edit

    Colin

Sign In or Register to comment.