jQuery DataTables - Filter column by exact match
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 )
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
$(document).ready( function() { $('#example').dataTable( { "oSearch": {"bSmart": false} } );} )
Try using the bSmart option and setting it to false
From the documentation
"When "bSmart" DataTables will use it's smart filtering methods (to word match at any point in the data), when false this will not be done."
UPDATE
I found this:
oSettings.aoPreSearchCols[ iCol ].sSearch = "^\\s*"+'1'+"\\s*$";oSettings.aoPreSearchCols[ iCol ].bRegex = false;oSettings.aoPreSearchCols[ iCol ].bSmart= false;
at this link http://www.datatables.net/forums/discussion/4096/filtering-an-exact-match/p1
looks like you can set bSmart
and bRegex
per column as well as specifying a manual regex per column.