How to tell DataTables where to insert the buttons

2019-09-18 14:01发布

I wanna archive something like this with datatables enter image description here

But I can't find a way how to tell datatable where to insert button copy, excel,PDF etc. Default insert button datatable will replace sorting entries like this

enter image description here

This is my code

<div class="box-header">
    <div class="buttonContainer"></div>
    <div class="pull-right">
       <button class="btn btn-primary form-button" id="addNew">Tambah Produk</button>
    </div> 
</div>

and

var dTable;
    dTable = $('#dataTable').DataTable({
      "bProcessing": true,
      "bAutoWidth": false,
      "responsive": true,
      "buttons": [ 'copy', 'excel','csv','pdf'],
    });

I wanna insert datatable buttons in buttonContainer

I found a reference how to do that in here dom datatable

but not quite understand how to implement it in my case

Please help

1条回答
一纸荒年 Trace。
2楼-- · 2019-09-18 14:23

SOLUTION

Use dom option with the value Bfrtip.

var dTable = $('#dataTable').DataTable({
   "dom": "Bfrtip"
   "bProcessing": true,
   "bAutoWidth": false,
   "responsive": true,
   "buttons": [ 'copy', 'excel','csv','pdf']
});

DEMO

See this jsFiddle for code and demonstration.

查看更多
登录 后发表回答