How can I access "HTML 5 data export" functionality via javascript?

How can I access "HTML 5 data export" functionality via javascript?

stergiosstergios Posts: 12Questions: 2Answers: 0

Description of problem:

Hi,

The "HTML 5 data export" via the Buttons extension works great for me. However, I prefer not to have the buttons displayed at all, and instead access the functionality through other means in my GUI.

Can someone point me in the right direction how I may achieve this?

Thanks,

Stergios

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765
    Answer ✓

    One way is to create hidden buttons and use button().trigger() to trigger the button you want. You can use the Direct Insertion method into a hidden div.

    There maybe other ways for this.

    Kevin

  • stergiosstergios Posts: 12Questions: 2Answers: 0

    Hey, that worked well. I have not hidden the buttons yet, but I did get them to work via other elements from within my GUI.

    At first I used:

    $(myDataTable.buttons().container()[0].children[index]).click() ;

    But after your suggestion I switched to:

    myDataTable.button( index ).trigger();

    Thanks for the guidance,

    Stergios

  • stergiosstergios Posts: 12Questions: 2Answers: 0

    As a follow up comment, I successfully have hidden the buttons with the export functionality intact and working as I access it from other parts of my GUI.

    However, I am confused by the example code. Is the 2nd argument in the call to the jQuery function '$()' in the Direct Insertion method necessary? Here's the example repeated:

    table.buttons().container()
    .appendTo( $('.col-sm-6:eq(0)', table.table().container() ) );

    What is the purpose of this argument:

    table.table().container()

    in the call to the Selector function '$()'

    $('.col-sm-6:eq(0)', table.table().container() )

    I ignored using the 2nd argument in my own code with no apparent problems.

    Thanks,

    Stergios

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    It just makes the selector more specific, but if it works without - go for it :)

    Colin

  • stergiosstergios Posts: 12Questions: 2Answers: 0

    I see. I'm so used to calling the selector function with multiple arguments in just one string such as

    $("div#id23 a.myClassName")

    I did not think about passing it multiple arguments, possibly as objects, to do the same. I learned something new!

    Again, thanks for the help!

    Stergios

This discussion has been closed.