Problem with buttons extension

Problem with buttons extension

gammonegammone Posts: 2Questions: 1Answers: 0
edited May 2016 in Free community support

Hi all,
i'm really new with datatables but found it very interesting. I'm trying to add to my page buttons extension but i'm not able to do so. In particular, buttons are not created in the page. I created an example of my code in this page (reference to JS rollover is related to the JS reported in JS section):

https://jsbin.com/quvexibupi/edit?html,js,output

I kindly ask someone to show me the correct way to display the buttons.

Thank you in advance

This question has an accepted answers - jump to answer

Answers

  • hullchullc Posts: 10Questions: 3Answers: 1
    edited May 2016 Answer ✓

    If you put the contents of:

    $('#futmcomm').DataTable( {
        autoFill: true,
        colReorder: true,
        select: true,
        dom: 'Blfrtip',
        buttons: ['copy', 'excel', 'pdf']
    } );
    

    Within the first DataTable function call, the buttons should appear. In fact, I'd just remove the second $('#futmcomm').DataTable( block altogether and put those options in the first block, so that it looks like this:

    $(document).ready(function() {
        $('#futcomm').DataTable( {
            data: commodity,
            columns: [
                { title: "Counter"},
                { title: "field1" },
                { title: "field2" },
                { title: "field3" },
                { title: "field4" }
            ],
            autoFill: true,
            colReorder: true,
            select: true,
            dom: 'Blfrtip',
            buttons: ['copy', 'excel', 'pdf']
    } );
    } );
    

    I tested that on jsbin and it seems to work.
    You really shouldn't need more than one $('#futmcomm').DataTable( call in your code.

  • gammonegammone Posts: 2Questions: 1Answers: 0

    Hi hullc,
    thank you fir your kindly reply.
    Your suggestion is perfect, I solved my problem and got what I wanted.
    thank you so much

This discussion has been closed.