How to tell DataTables where to insert the buttons export

末鹿安然 提交于 2020-01-06 08:36:14

问题


I wanna archive something like this with datatables

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

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:


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.



来源:https://stackoverflow.com/questions/33950557/how-to-tell-datatables-where-to-insert-the-buttons-export

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!