No button appears

No button appears

hellsinghellsing Posts: 22Questions: 8Answers: 0
edited April 2019 in Free community support

Hi All,

I have a quite simple setup: datatables, buttons a language pack and their css files are loaded from cdn (checked, they are loaded). Then I initialize like this:

$(document).ready( function () {
    $('#people').DataTable( {
        buttons: [
            'copy', 'excel', 'pdf'
        ],
        "language": {
            "url": "//cdn.datatables.net/plug-ins/1.10.19/i18n/Hungarian.json"
        }
    });
    $.fn.dataTable.ext.order.intl( 'hu' );
});

On load DT works perfectly except that there are no buttons nor any error message on the console. It doesn't matter if I use the dom option or not.

Any idea what went wrong?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Hi @hellsing ,

    You need to modify dom to include the buttons - see the example here.

    Cheers,

    Colin

  • hellsinghellsing Posts: 22Questions: 8Answers: 0

    Hi Colin,

    I already tried both dom: 'Bfrtip' and 'B<"clear">lfrtip' but they don't make any change.

    Thanks,

    h.

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Hi @hellsing ,

    Have you also included the necessary JS and CSS files - you see those on the examples here.

    If still no joy, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • hellsinghellsing Posts: 22Questions: 8Answers: 0

    Hi @colin,

    Yes, everything is included and loaded (checked twice). I'm on localhost but will figure out how to make it accessible.

    Thanks,

    hellsing

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,770

    It might be easier to build up a test case to show the issue than to try making your localhost code available. Since the problem is not reliant on your specific data you can use simulated data.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • hellsinghellsing Posts: 22Questions: 8Answers: 0

    You're absolutely right :) Here we go. I made a table with fake data. DT works but no export buttons appear.

    Thanks of dealing with it.

  • hellsinghellsing Posts: 22Questions: 8Answers: 0

    I just realized live.datatables.net uses jQuery 1.11.3 and I'm on 3.1.1. Is this causing the error? I don't have any error msg on console.

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,770
    Answer ✓

    Datatables suppots jQuery 1.7 and new according to this doc:
    https://datatables.net/manual/installation#Dependencies

    The problem is you didn't include the buttons JS and CSS files. I updated your example to include the necessary files and now it works:
    http://live.datatables.net/botuwaku/2/edit

    This page describes the requirements:
    https://datatables.net/extensions/buttons/

    The Download builder can be used to obtain the needed files for buttons or any other extension.

    Kevin

  • hellsinghellsing Posts: 22Questions: 8Answers: 0

    [user slaps his forehead and feels himself utterly idiot]

    Thanks :)

This discussion has been closed.