How to filter ?
How to filter ?
Hi there,
I would like to ask how to filter Datatbles, I have found the example;
https://datatables.net/examples/api/regex.html
and used the code below to search column No.2 for "New project2", but it did not work.
$('#example').DataTable().column( 2 ).search("New project2",True,True).draw();
I would like to filter the table by the given project name.
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
This discussion has been closed.
Answers
One problem might be
True. Javascript usestruenotTrue. If this doesn't help then post a link to your page or a test case replicating the problem.https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Thank you, It evenatualy worked, but I had to use List inside column.
$('#example').DataTable().column( [2] ).search("New project2",True,True).draw();That doesn't sound right. IIRC you are using Python. Booleans in Python begin with uppercase, like
True. However booleans in Javascript are all lower case, liketrue. This messes me up too. You should be getting a console log error when trying to useTrue.Kevin
Sorry, yes the right line is in normal, non-capital true;
$('#example').DataTable().column( [2] ).search("New project2",true,true).draw();I also noticed that I want to search "New project" the result is including other records that includes the search word. I also get "New project2" or New project1" too.
How can I make search strict to find exactly search words only?
Use.a regex expression, something like this:
Also you will want to set the 3rd parameter to false to turn off Smart Search. See the
search()docs for details.Kevin