Changing DOM Element Position of searchbox in datatables

前端 未结 8 1790
春和景丽
春和景丽 2021-01-30 14:57

Actually I am new to jQuery datatables plugin.

I have attached the plugin to my tables using this method using this code.

$(document).ready(function() 
         


        
相关标签:
8条回答
  • 2021-01-30 15:30

    you can change the style of the search input very easy with css

    in css File:

    .dataTables_filter input {
         background: blue;
    }
    

    With Javascript

    $(".dataTables_filter input").css({ "background" :"blue" });
    

    Try it by paste this to your console.

    0 讨论(0)
  • 2021-01-30 15:33

    To remove the filter options you can use css as mentioned in other answers or you can remove it in the initialisation of the datatable using:

    $("#table").dataTable({"bFilter": false}); //disables filter input
    

    or by using sDom attribute like this:

     "sDom": '<"H"lr>t<"F"ip>' //when bJuery is true
    

    See here http://datatables.net/usage/options#sDom for more options.

    Now about using your own text field as a filter box then just attach a keypress handler to it, and use the fnFilter option like this:

    $(document).ready(function() 
    
         oTable = $('#table_id').dataTable({
             "sDom": '<"H"lr>t<"F"ip>' 
         });
         $('#myInputTextField').keypress(function(){
             oTable.fnFilter( $(this).val() );
         });
     });
    
    0 讨论(0)
提交回复
热议问题