Custom Toolbar button with hyperlink as action

Custom Toolbar button with hyperlink as action

iecwebmastiecwebmast Posts: 66Questions: 9Answers: 1

Hello,
I need to add a custom toolbar button with a download zip file link. How can I define the action to be a hyperlink?

$('#myTable').DataTable( {
    ajax: '/api/data'
    buttons: [
        {
            text: 'ZIP all',
           titleAttr: 'Download zip of ALL files',
            action: ???
            }
        }
    ]
} );

Answers

  • iecwebmastiecwebmast Posts: 66Questions: 9Answers: 1

    I've found this solution:

    $('#myTable').DataTable( {
        ajax: '/api/data'
        buttons: [
            {
                text: 'ZIP all',
                titleAttr: 'Download zip of ALL files',
                action: function ( e, dt, node, config ) {
                    onclick (window.location.href='http://www.datatables.net')
                }
            }
        ]
    } );
    
  • iecwebmastiecwebmast Posts: 66Questions: 9Answers: 1

    Unfortunately, it I am not able to open in a new window.
    onclick (window.open='http:// does not work...
    What would be the correct syntax?

  • iecwebmastiecwebmast Posts: 66Questions: 9Answers: 1

    This syntax worked, without the onclick
    window.open('http://datatables.net','','width=800,height=800');

This discussion has been closed.