Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter dataTables.net without included filter-box input

I want to use the filter function of DataTables, but don't want to use their search box with it.

In their docs under bFilter it says:

Note that if you wish to use filtering in DataTables this must remain 'true' - to remove the default filtering input box and retain filtering abilities, please use

after which the sentence is left incomplete.

I tried:

var oTable = $('#sortable').dataTable({
    'bPaginate':false,
    'bInfo':false,
    'bFilter': true // displays Search box, setting false removes filter ability all together
});
$('#Accumulate').click(function(){
    oTable.fnFilter("Accumulate");
});
like image 661
Pratyush Avatar asked Mar 31 '12 09:03

Pratyush


3 Answers

You can also hide is using css class

<style type="text/css">
.dataTables_filter {
     display: none;
}
</style> 
like image 80
Daniel Avatar answered Sep 27 '22 22:09

Daniel


Pratyush,

Pure cosmetic showing and hiding of different UI elements is done with the sDom parameter:

http://datatables.net/usage/options#sDom

Note that the required syntax is different depending on if you're using jQuery UI or not.

like image 25
Greg Pettit Avatar answered Sep 27 '22 20:09

Greg Pettit


Use (potentially speed up datatable initialization as avoid some calculation):

$("#table").dataTable({"bFilter": false});

or any sDom without f option (refer to official docs http://datatables.net/usage/options#sDom for list of available options):

$("#table").dataTable({"sDom": '...t...'});

Look for same options at official support site: http://datatables.net/forums/discussion/289/disable-search-filter-text-box

like image 26
gavenkoa Avatar answered Sep 27 '22 22:09

gavenkoa