最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to position DataTables buttons outside of table wrapper - Stack Overflow

programmeradmin4浏览0评论

Can you please take a look at This Demo and let me know how I can re-position the dataTabes buttons somewhere else , let say inside .panel-heading calss and apply btn-sm to them?

Here is the very basic standard format which I have now

$(document).ready(function() {
    $('#example').DataTable({
         responsive: true,
         dom: 'Bfrtip',
         buttons: ['copy', 'excel', 'pdf', 'csv']
    });
});

and as you are fully aware it is adding the buttons inside #example-wrapper

Can you please take a look at This Demo and let me know how I can re-position the dataTabes buttons somewhere else , let say inside .panel-heading calss and apply btn-sm to them?

Here is the very basic standard format which I have now

$(document).ready(function() {
    $('#example').DataTable({
         responsive: true,
         dom: 'Bfrtip',
         buttons: ['copy', 'excel', 'pdf', 'csv']
    });
});

and as you are fully aware it is adding the buttons inside #example-wrapper

Share Improve this question edited Apr 3, 2021 at 13:17 Syscall 19.8k10 gold badges43 silver badges58 bronze badges asked Oct 28, 2015 at 19:22 BehseiniBehseini 6,32823 gold badges86 silver badges139 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Sure. Use jQuery appendTo(), like this:

//create DataTable first, then...
$("#example_wrapper > .dt-buttons").appendTo("div.panel-heading");

See this fiddle: https://jsfiddle/gz586wpj/1/

There's also a prependTo() that you can consider.

发布评论

评论列表(0)

  1. 暂无评论