How to put id on a button?
How to put id on a button?
syntaxerr0r
Posts: 3Questions: 1Answers: 0
I just started learning datatables only today and I read much infos on FAQs but can't find any solutions there.
I'm trying to put on a button with id getting (data[0]). On click a div with id+data[0] will collapse containing options and forms for the selected row..
here is my current code
var dataTable = $('#testT').DataTable( {
"processing": true,
"serverSide": true,
"ajax":{
url :"search_e_que.php",
type: "post"
},
"columnDefs": [ {
"targets": -1,
"data": null,
"defaultContent": "\
<button class='btn btn-outline-dark' type='button' id='arcb-' title='Archive'>\
<span class='fa fa-file-archive'></span>\
</button>\
<div class='collapse' id='arcc-'>\
Possible Options Here\
</div>",
},
{
// hide id_number column
"targets":[0],
"visible":false,
"searchable":false
} ],
} );
$('#testT tbody').on( 'click', '#arcb-', function () {
var data = dataTable.row( $(this).parents('tr') ).data();
var id_tag = $(this).attr('id')+data[0];
var holder_tag = $('#arcc-').attr('id')+data[0];
$('#arcc-').collapse();
} );
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @syntaxerr0r ,
I think on line 34 of your code, you can just use
That will get the
<div>
after the button in that cell.Hope that does the trick,
Cheers,
Colin
You are a life saver it worked ! Thank you !
i found another answer.. columns.render did the trick..