how can I add a button in each table row that downloads a different linked file?

how can I add a button in each table row that downloads a different linked file?

lpacelpace Posts: 12Questions: 6Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • lpacelpace Posts: 12Questions: 6Answers: 0

    here's what I had so far. it shows the link in the column, but I'd prefer to have a button there
    var my_datatable = $('#my_datatable').DataTable({
    'ajax': {
    'url': 'http://localhost:9090/dashboard-data'
    },
    'columnDefs':[
    {
    'data':'null',
    'defaultContent':'<button>Download</button>',
    'targets':'-1'
    }
    ],
    'dom': 'lfrtBip',
    'buttons': [
    {'extend': 'csv',
    'text': 'Export',
    exportOptions: {
    modifier: {
    search: 'none'
    }
    }
    },
    {
    'text': 'Reload',
    'action': function ( e, dt, node, config )
    {
    dt.ajax.reload();
    }
    }
    ],
    'select':'true',

                        'columns': [
                            { 'data': 'ORDERNUM' },
                            { 'data': 'CUSTOMER_NAME' },
                            {'data':  'LOCATION'},
                            {'data':  'DOWNLOAD'}                       
                                   ]
                    });
    
  • Aryan1703Aryan1703 Posts: 65Questions: 15Answers: 1
    edited May 6

    If you want to add button in each row you could simply use the render function to do that, something like this


    { data: "docStatus", className: 'text-center', render: function (data, type, row) { if (data==1 ) { return '<a href="../yourdestination=' + data + '" target="_blank"><button>Submit</button></a>'; } else { return 'Text'; } },
Sign In or Register to comment.