Datatables jquery-ui buttons and ajax

Datatables jquery-ui buttons and ajax

nickidk4nickidk4 Posts: 2Questions: 1Answers: 0

Buttons does not work on datatables with jquery-ui styling and ajax sourced data.

The example at: https://datatables.net/extensions/buttons/examples/styling/jqueryui.html works fine.

But if you try using ajax sourced data, the button wont appear. Its like it tries to add the button before table is ready.

Can someone give an example on how to make this work, without using the dom option?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,277Questions: 26Answers: 4,766
    Answer ✓

    Due to the async nature of ajax you probably will need to use initComplete or the init event to install the buttons. Otherwise the table.buttons().container().insertBefore( '#example_filter' ); code is executed too soon. Here is an example:
    http://live.datatables.net/cecemole/1/edit

    Kevin

  • nickidk4nickidk4 Posts: 2Questions: 1Answers: 0

    Hey kthorngren
    Thanks for the answer! This did help me with a solution. Though my real problem was that I was importing both datatables v1.10.18 and v1.10.20.
    Removing one of the imports solved my issue with the button not appearing.

This discussion has been closed.