Datatables - Search Box outside datatable

前端 未结 11 1333
攒了一身酷
攒了一身酷 2020-11-30 17:08

I\'m using DataTables (datatables.net) and I would like my search box to be outside of the table (for example in my header div).

Is this possible ?

11条回答
  •  伪装坚强ぢ
    2020-11-30 17:44

    I had the same problem.

    I tried all alternatives posted, but no work, I used a way that is not right but it worked perfectly.

    Example search input

     
    

    the jquery code

    $('#listingData').dataTable({
      responsive: true,
      "bFilter": true // show search input
    });
    $("#listingData_filter").addClass("hidden"); // hidden search input
    
    $("#serachInput").on("input", function (e) {
       e.preventDefault();
       $('#listingData').DataTable().search($(this).val()).draw();
    });
    

提交回复
热议问题