0

I would like to know if it was possible to search for 2 differents things and then redraw the datatable.

I'm now using this :

 var table = $('#something').DataTable();
    table
        .search(something1)
        .draw();

It is possible to do something like

table
.search(something1 || something2)
.draw

Thanks!

2 Answers2

0

The documentation says that it only accepts a string, but you can use regex.

.search(/something1|something2/, true)

You can use variables in regex.

Zoe Edwards
  • 12,999
  • 3
  • 24
  • 43
  • Do I have to import something if I want to use regex? If not it seems to not be working for me :( – zwcntvf Apr 05 '18 at 10:16
0

For me it worked by using regex.

var table = $('#myTable').DataTable(); 
var temp = 'something1|something2';
        table.search(temp, true, false).draw()