Two buttons in a row with columDefs and render
Two buttons in a row with columDefs and render
neelsf
Posts: 15Questions: 6Answers: 1
I get one column with a button to work 100% and pass variables to the url etc. How do one add a 2nd button in the same row, to open a different form with the same variables in the URL . I just love datatables, but this problem has flattened me for days now.
"columnDefs": [ { "className": "dt-body-center", "targets": "_all",
"targets": [0,1]
"render": function ( data, type, row ) {
return '<a class="btn btn-info btn-sm" href="transact/rdmicn1.php?update=1&demandercode=' + row[2] + ' &facility=' + row[1] + ' &order_no=' + row[4] + ' ">' + data + 'Save RDM file</a>';
return '<a class="btn btn-info btn-sm" href="transact/rdmicn2.php?update=1&demandercode=' + row[2] + ' &facility=' + row[1] + ' &order_no=' + row[4] + ' ">' + data + 'Submit to Depot</a>';
}
} ],
EDIT: Updated to use Markdown Code formatting.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Looks like you have two return statements. That won't work - only the first return statement is used. You will need to combine both buttons into one string then return that string.
Kevin
Thx for suggestions. Any examples please?
Another issue with your code is you need a comma after
"targets": [0,1]
, like this"targets": [0,1],
. If you look at the browser's console you should see a syntax error.Here is an example of two buttons with
columns.render
:http://live.datatables.net/qemodapi/1/edit
The same example using
columns.defaultContent
:http://live.datatables.net/xijecupo/1/edit
Kevin
Thx