I need to get the values from the hidden column of a Jquery Datatables where the checkbox has been selected (in the first visible column). So far I've got
bodytable$ = $('#dataTable').dataTable({
"bJQueryUI" : true,
"bPaginate" : true,
"bSort" : false,
"bFilter": false,
"aoColumns": [{"bVisible": false},
{"bVisible": true},
{"bVisible": true},
{"bVisible": true}],
"oLanguage": {
"sEmptyTable": '',
"sInfoEmpty": '',
"sZeroRecords": ''
}
});
and I'm getting the values from the hidden column with
var checkIds = [];
$('input[type="checkbox"]:checked', bodytable$.fnGetNodes()).each(function(i){
var tr = $(this).closest('tr');
var rowData = bodytable$.fnGetData(tr);
checkIds.push(rowData[0]);
});
alert(checkIds);
This fails on the line var rowData = bodytable$.fnGetData(tr); with Firefox debug giving the error message TypeError: a.nodeName is undefined
I have to go through the DataTable API because the hidden column doesn't actually appear in the html loaded into the browser and, because I want to be able to select the data values when the selected checkboxes aren't on the same page.
Following on from mainguys response, and using CSS to hide the column instead of the bVisible property, I can now get what I want with;
var checkIds = [];
$('input[type="checkbox"]:checked', bodytable$.fnGetNodes()).each(function(i){
var tr = $(this).closest('tr');
checkIds.push($(tr).find('td:eq(0)').text());
});
alert(checkIds);