jQuery DataTables - Filter column by exact match

jquery datatables fnfilter exact match
datatables {search : "applied"}
datatable search event
datatables data-search
datatable filter
datatables search regex
datatables search callback
datatables column search

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?

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 )

Search exact match, My website shows a huge list (4700+ entries, 4 columns) and I want to filter it with the search box. However, it works with a “contains” and I would like an “exact match”. I don't see any option You can try the example here: I am using jQuery Datatables plugin in my application. I am trying to search for a string that exactly matches the data in a column. I checked jQuery DataTables - Filter column by exact match which

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

search(), If data is found matching in any column, then the whole row is matched and As DataTables provides on-the-fly filtering with immediate feedback to the user, for example to perform whole word exact matching, you would need to enable the  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.

how can I filter jquery data table with exact match, dataTable having the depot number exact match with variable. That means I want to filter the column 1 having the value of 1 and 3 and 5. Hey. When filtering specific columns using a select - I don't want it to filter smartly. If I filter by code for example, and I look for '1', I don't want it to find all the '1' as well as all of the '11'.

If you want the exact match from the beginning you can try this code,

    var table = $('#myTable').DataTable()
    $('#filterrow > th:nth-child(2) > input').on( 'keyup change', function () {
        table
        .column( $(this).parent().index()+':visible' )
        .search( "^" + this.value, true, false, true )
        .draw();
    } );

DataTables - Search for exact match - JSFiddle, JavaScript + jQuery 1.11.0 Tidy. 9. 1. $(document).ready(function (){. 2. var table = $('#example').DataTable();. 3. 4. table. 5 .column(5).search('^Completed$',  I'm using DataTables thru the WordPress plugin. My website shows a huge list (4700+ entries, 4 columns) and I want to filter it with the search box. However, it works with a “contains” and I would like an “exact match”. I don't see any option for that.

You can use regular expression for exact matching as following:

var table = $('#dt').DataTable();

$('#column3_search').on('keyup', function () {
    // Note: column() accepts zero-based index meaning the index of first column is 0, second column is 1 and so on.
    // We use `2` here as we are accessing 3rd column whose index is 2.
    table.column(2)
         .search("^" + this.value + "$", true, false, true)
         .draw();
});

The syntax of the search function is:

search(input, regex, smart_search, case_insensitive)

We disable smart search in this case because search function uses regular expression internally when smart search is set to true. Otherwise, this creates conflict between our regular expression and the one that is used by search function.

For more information, check out the following documentation from DataTable:

column().search()

Hope it's helpful!

DataTables example, Note that the column().search()DT method in this particular case performs an exact match through the use of a custom regular expression and disabling  This example shows FixedColumns being configured with individual column filtering abilities. Note that the data-index attribute is attached to the input elements in order to track which column the input should filter. The event handler then uses this with the column () selector method to search the corresponding column. a.satou@datatables.net.

DataTables example, Note that the column().search()DT method in this particular case performs an exact match through the use of a custom regular expression and disabling  jQuery DataTables-Filter column by exact match (6) 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.

"Searching for exact terms in filter and global search" (#919044 , wp-content/plugins/wpdatatables/assets/js/jquery-datatables/jquery.dataTables.​columnFilter.js. For filter type Number to search exact match try  I have the string variable var filtertext= '1,3,5' I want to filter the datatable table = $('#DepotID').dataTable having the depot number exact match with variable. When I filter the data table, the record should not be displayed having the depot id value 100,303. it have to be filtered exact match of 1,2,3.

Tables: Filtering on an exact match · Issue #8500 · wet-boew/wet , I'm following the DataTables filtering example, but in my case, a select list used as a filter has a numeric for a value and a string for Tables: Filtering on an exact match #8500 Image a filter has values like this for column 7:. jQuery DataTables plug-in employs 'multiple-criteria-multiple-column' filtering using DataTables API. In addition to conventional 'match all the criteria' logic, 'append to selection' operation is available.

Comments
  • Hi sir, I'm having the same problem. I was wondering where should I place the code you provided? Because I want to try it if it will solve my problem too. Hope you'll reply.
  • Hey, I was able to solve the problem of exact match on multiple ID's separated by commas. Here is a working fiddle for any one else who encounters the problem. jsfiddle.net/digvijayad/0m94e2v7 Note: For my case, ids were unique across rows, i.e when searched only 1 row would return.
  • Not quite what I am looking for. So basically I have 3 custom search fields I use to filter the table. I only want one of the fields to use an exact search. For the other fields, I want them to still use the smart search.
  • Also on a side note, the bSmart basically means if I type in "John Smith", it will find any combination of those words (i.e. "Smith John", "John Jack Smith", etc etc.)
  • $('#filterrow > th:nth-child(2) > input') is a selector
  • Didn't return any results...?