reverse filter

reverse filter

dairycow2dairycow2 Posts: 2Questions: 0Answers: 0
edited August 2010 in General
I apologize in advance. I have a feeling there is a very simple answer for this but can't figure it out. I'm trying to filter on records that are not equal to the string. E.G. the example from the documentation will find all records matching 'test string', I want to find all records that do not match 'test string'.

var oTable;

$(document).ready(function() {
oTable = $('#example').dataTable();

/* Filter immediately */
oTable.fnFilter( 'test string' );
} );

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You need to use a regular expression to match for "not": http://datatables.net/api#fnFilter . You probably want to disable smart filtering when using custom regular expressions, since the regex that DataTables uses internally can create confusing combinations with your own!

    Allan
  • dairycow2dairycow2 Posts: 2Questions: 0Answers: 0
    thanks allan. for any other newbie looking for the code to do this, here was my code for filtering out the string 'DP', not sure how to do it exactly for the initial example as I don't know how to specify the space in regex:

    tableToFilter.fnFilter( '^(?:(?!DP).)*$\r?\n?', 11, true, false);
This discussion has been closed.