how get current value of checkbox?
how get current value of checkbox?

I use this code to define check boxes in my table:
columnDefs: [{targets: [2,4],
render: function ( data, type, row ) {
if ( type === 'display' ) {
return '<input type="checkbox" ' + ((data == 1) ? 'checked' : '') + ' id="input' + row.id + '" class="filter-ck" />';
}
return data;
},
className: "dt-body-center"
},
{targets: 0, className: "dt-body-center"},
],
select: {
style: 'os',
selector: 'td:not(:nth-child(2))'
},
and
then I do:
var table = $('#GRID_1').DataTable();
$('#GRID_1 tbody').on( 'click', 'tr', function () {
if ( $(this).hasClass('selected') ) {
$(this).removeClass('selected');
}
else {
table.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
alert(table.cell('.selected',2).data());
}
} );
} );
but
table.cell('.selected',2).data() gives me original data from cell.
How can I get current value of check box?
Thank you.
Kamo.
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You can use
cells().render()
to get the display values - something liketable.cells(null, 2).render('display')
.Colin
it gives me:
<input type="checkbox" id="inputundefined" class="filter-ck">
or
<input type="checkbox" checked id="inputundefined" class="filter-ck">
from original data.
I cannot see 'checked' as current value.
Any other way I can get this value?
The easiest way to get the checkbox checked state is with jQuery. See this example:
http://live.datatables.net/xetowopa/1/edit
Kevin
Thank you! It work's!
How can I set this checkbox value in a specific cell (I have 2 columns with check boxes) data?
I like to see this data later in
table.cell('.selected',2).data().
Is it possible?