jQuery DataTables - Filter column by exact match

JimmyJammed picture JimmyJammed · Dec 22, 2011 · Viewed 46.1k times · Source

Trying to only display exact matches to the search term entered in the search bar.

For instance, I have a search bar that filters by ID#. I want only records that match the exact # entered to display.

So if 123 is entered, I don't want 12345, 91239, etc etc to be displayed. Only 123.

Saw some info about bRegex on the FAQ page, but it's not working for me. Any ideas?

Answer

Neeno Xavier picture Neeno Xavier · May 29, 2014

This will give you exact result for a column.

 table.column(i)
 .search("^" + $(this).val() + "$", true, false, true)
 .draw();

ie . search( input , regex, smart , caseInsen )