-3

On my site I am using the plugin wpDataTables based on jQuery DataTables.

My first column in the price list table contains values - AUR, D, DH, etc. Table is programmed to show only first 6 results out of many.

Here is the problem: If I want user to find value D and user types in the search field D, you'll get a list with values DH.

It happens because by default jQuery DataTables plugin finds records that contain value D (such as DH, etc), but I want it to perform exact match.

Please see Excel spreadsheet containing all records for reference.

Gyrocode.com
  • 57,606
  • 14
  • 150
  • 185
  • Where have you implemented the logic to search the input query ? – Rayon Jul 24 '15 at 13:17
  • It's in an excel sheet: http://baudirekt.itstoolong.com/wp-content/uploads/2015/05/baudirektEH125.xlsx – user3350511 Jul 24 '15 at 13:41
  • I need to see the logic..Can you share that ? – Rayon Jul 24 '15 at 13:51
  • Sorry for my english. The prices are for different regions in Germany. The letters (one, two or three letters) are based on german license plates. So region 1 is VEC, region 2 are HB, CLP, DH and so. If you want to see your price you just type in the letters for a given region. The .js from datatables is here: http://cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js – user3350511 Jul 24 '15 at 14:00
  • Found a similar question here: http://stackoverflow.com/questions/8609577/jquery-datatables-filter-column-by-exact-match/23931504#23931504 Would this solve the problem? Anyway, I am getting closer but I can't see how to implement this. – user3350511 Jul 24 '15 at 15:49
  • @ Rayon Dabre See edited question: It happens because by default jQuery DataTables plugin finds records that contain value D (such as DH, etc), but I want it to perform exact match. – user3350511 Jul 24 '15 at 17:13

1 Answers1

0

You need to follow this documentation and end up with something like this:

table.column( 1 ).search( '^My exact match$', true, false );

You can also use quotes when you input or add them before passing to the search function:

 table.search( '"My exact match"' );

Documentation: https://datatables.net/reference/api/column().search()

jonmrich
  • 4,233
  • 5
  • 42
  • 94