简体   繁体   English

如何告诉DataTables导出按钮的插入位置

[英]How to tell DataTables where to insert the buttons export

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 但是我找不到一种方法来告诉数据表在哪里插入按钮副本,excel,PDF等。默认的插入按钮数据sorting entries将替换这样的sorting entries

在此处输入图片说明

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 我想在buttonContainer插入数据表datatable buttons

I found a reference how to do that in here dom datatable 我在这里的dom数据表中找到了参考方法

but not quite understand how to implement it in my case 但是我不太了解如何实施

Please help 请帮忙

SOLUTION

Use dom option with the value Bfrtip . 使用值为Bfrtip dom选项。

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. 有关代码和演示,请参见此jsFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM