Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically search a table with jQuery DataTables

I am using jQuery DataTables 1.10.9 and jQuery 1.8.3. I'm trying to programmatically search in that, but without success.

I already tried:

function applyFilter(filter) {
    $("#dataTable").filter(filter);
}

and

function applyFilter(filter) {
    $("#dataTable").fnFilter(filter);
}
like image 849
Ricardo Silva Avatar asked Oct 27 '15 14:10

Ricardo Silva


2 Answers

Use search() API method to perform the search, see the code below:

function applyFilter(filter) {
    $('#dataTable').DataTable().search(filter).draw();
}
like image 187
Gyrocode.com Avatar answered Oct 14 '22 10:10

Gyrocode.com


$("#dataTable").dataTable().fnFilter('something')
like image 27
boubkhaled Avatar answered Oct 14 '22 11:10

boubkhaled