Change Button Position with div Container

Change Button Position with div Container

KodaKoda Posts: 2Questions: 1Answers: 0
edited October 2022 in Free community support

I use this to change the button Position: https://datatables.net/forums/discussion/66759/position-of-export-buttons

But as soon as I insert languages the buttons are no longer displayed at the new position

let table = $('.datatable').DataTable({
language: {
url: languages['{{ auth()->user()->locale }}']
},
......

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    Answer ✓

    The language.url option is asynchronous meaning the table variable is not ready when this code is executed:

          table.buttons().container()
        .appendTo( $('.my-buttons' ) );
    

    Move it into initComplete and replace table with this.api() to look like this:

          this.api().buttons().container()
        .appendTo( $('.my-buttons' ) );
    

    Kevin

  • KodaKoda Posts: 2Questions: 1Answers: 0

    Great. Thank you Kevin

Sign In or Register to comment.