Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have a datatable that has 7 columns. It should not display the data in datatable that starts with "ABC" text for column index 0.Tried the below solution but didn't work Please help.

What I have tried:

$(document).ready( function () {
$('#ttable').DataTable( {
'order': [[ 0, 'asc' ]],
'pageLength': 10
} );
oTable = $('#ttable').dataTable();
oTable.fnFilter('ABC', 0, true, false);
} );
Posted
Updated 7-Feb-17 5:51am

1 solution

According to the documentation[^] of the legacy methods, when you pass true as the 3rd parameter, the 1st parameter is treated as a Regular Expression[^].

So, to filter out any rows where the first column starts with "ABC", use:
oTable.fnFilter('^(?!ABC)', 0, true, false);
 
Share this answer
 
v2
Comments
User1454 7-Feb-17 23:01pm    
Wow! Its working .. thanks a lot!! .. So what about the 3rd parameter?
Richard Deeming 8-Feb-17 7:45am    
Sorry, I misread the documentation. The 3rd parameter controls whether the string is a regular expression; the 4th parameter turns off "smart filtering". If you're using a regular expression, you'll always want to turn off smart filtering too.
User1454 9-Feb-17 0:38am    
:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900