Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery DataTables - Filter column by exact match

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?

like image 764
JimmyJammed Avatar asked Dec 22 '11 20:12

JimmyJammed


2 Answers

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 )

like image 156
Neeno Xavier Avatar answered Sep 23 '22 17:09

Neeno Xavier


Ok solved the problem. However, since the column I am using the exact match on sometimes contains multiple ID #s seperated by commas, I wont be able to use an exact match search.

But for those interested, here is the answer:

oTable.fnFilter( "^"+TERM+"$", COLUMN , true); //Term, Column #, RegExp Filter 
like image 28
JimmyJammed Avatar answered Sep 19 '22 17:09

JimmyJammed