DataTables 3 buttons don't work in Bootstrap 4

DataTables 3 buttons don't work in Bootstrap 4

toxpaltoxpal Posts: 12Questions: 2Answers: 0

Right after upgrading to DT3, I noticed that Column Visibility and Search Builder buttons don't work on my website (using Bootstrap 4). No errors in console, they just don't work (while export buttons work fine).

So I created a fresh DT3/BS4 page at https://jsfiddle.net/kjhfu6dz/ and copied exact HTML/JS code from example ( https://datatables.net/examples/buttons/html5/columns.html ) - still the same problem (clicking Column Visibility button does nothing).

If I select DataTables Styling instead of Bootstrap4 Styling in Download Builder, the button starts working immediately, which confirms the problem is not in my HTML/JS code, but in DT3 itself. Any suggestions?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 65,825Questions: 1Answers: 10,952 Site admin
    Answer ✓

    Hi,

    Apologies - you've found a bug there. I've committed a fix and it will shortly be in the nightly build, and then the next release (I'll probably aim to get a new Buttons release done by the end of the week to see if anything else comes in, in the meantime).

    The workaround is to add:

    DataTable.Buttons.defaults.dom.collection.container.className = 'dropdown-menu show dt-button-collection';
    

    before you initialise the DataTable.

    Many thanks for letting me know about this!

    Allan

  • toxpaltoxpal Posts: 12Questions: 2Answers: 0

    Well, many thanks to you for providing a working solution just in 2 hours after bug was reported!

  • allanallan Posts: 65,825Questions: 1Answers: 10,952 Site admin

    You are most welcome. Frustrated that the bug was there at all - not sure how I missed it, but that's more or less how most bugs are!

    Allan

Sign In or Register to comment.