jQuery DataTables: hide search bar

后端 未结 4 1290
悲哀的现实
悲哀的现实 2021-02-14 13:33

I seem not able to hide DataTables default search bar. So far, I have tried solution from this thread, but setting bFilter:false disables filtering entirely, so my

4条回答
  •  说谎
    说谎 (楼主)
    2021-02-14 14:07

    Simply add this class in your css - .dataTables_filter, .dataTables_info { display: none; }

    The live instance -

    $(document).ready(function () {
        let table = $('#mytable').DataTable();
        $('#mytable tfoot th').each(function (i) {
            let title = $('#mytable thead th').eq($(this).index()).text();
            $(this).html('');
        });
        $(table.table().container()).on('keyup', 'tfoot input', function () {
            table.column($(this).data('index'))
                .search(this.value)
                .draw();
        });
    });
    .dataTables_filter, .dataTables_info { display: none; }
    
    
    
    
        
    name type color
    apple fruit red
    banana fruit yellow
    carrot vegie red
    potato vegie brown

提交回复
热议问题