Appending Buttons to existing dropdown

Appending Buttons to existing dropdown

fischerfischer Posts: 4Questions: 3Answers: 0

Hi.

I would like to append the contents of export Buttons menu to an existing dropdown on the page.

Current code:

 var exportBtn = new $.fn.dataTable.Buttons(table, {
        buttons: [{
            extend: 'collection',
            text: '<i class="mdi mdi-dots-horizontal mdi-icons-table"></i>',
            className: 'btn-fw-grey border-0 with-data-toggle',
            buttons: [{
                    text: '<div class="pt-3" style="text-transform: uppercase">exportieren</div>'
                },
                {
                    extend: 'copy',
                    text: '<a class="dropdown-item pl-0" href="#"><i class="mdi mdi-content-copy pr-2"></i>Kopieren</a>',

                },
                {
                    extend: 'pdf',
                    orientation: 'landscape',
                    pageSize: 'LEGAL',
                    text: '<a class="dropdown-item pl-0" href="#"><i class="mdi mdi-content-copy pr-2"></i>PDF</a>'
                },

                {
                    extend: 'excel',
                    text: '<a class="dropdown-item pl-0" href="#"><i class="mdi mdi-content-copy pr-2"></i>Excel</a>'
                }
            ]
        }]
    });

    exportBtn.container().appendTo(filterColumn);

Which comfortably places the export Buttons menu at a default position relative to the table.

What I would like now is something like:

    if(options.buttonsAt) exportBtn.ACTUAL_BUTTONS().appendTo($(options.buttonsAt));  // I'd like a call like this.
    else exportBtn.container().appendTo(filterColumn);

Can I get hold of the actual buttons as opposed to the dropdown toggle?
Or is there another solution to achieve the effect?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 8,013Questions: 0Answers: 1,348
    Answer ✓

    This example here should help, it shows how you can create a button set and append it to any element on the page.

    Colin

Sign In or Register to comment.