buttons().container().appendTo does not work when using language.url

buttons().container().appendTo does not work when using language.url

berndy2001berndy2001 Posts: 7Questions: 2Answers: 0
edited June 2021 in Buttons

I want to move the buttons into a custom div, for this I have used oTable.buttons().container().appendTo($('#myButtons'));. Unfortunately it did not work. By testing I found out that it is because of language.url.

Example (see the position of the excel-Button):
not working: http://live.datatables.net/zasasuxa/3/edit
working: http://live.datatables.net/winisefu/5/edit

What is the correct way to use both?

Thank you!

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    It's because of the Ajax nature of the language URL : you can move it into initComplete like this: http://live.datatables.net/zasasuxa/3/edit

    This thread here also discusses that,

    Colin

  • berndy2001berndy2001 Posts: 7Questions: 2Answers: 0

    Hello Colin,

    Thanks for your answer. I managed to do this with initComplete, but of course the button now appears after other buttons (which are custom buttons).

    Since I don't like that optically, I have now solved it with another button which triggers the excel-button

    $('#exportexcel').click(function() {
    oTable.button( '0,0' ).trigger();
    });
    
Sign In or Register to comment.