I have a jquery datatable, and have checkboxes which set the row selected class to the rows which are selected. However when I try to get the first column data from these selected rows, it gives me objects.
I am unable to get to the problem inspire of going through a number of posts on the subjects on the data tables and stack overflow forums.
The codes are provided below.
Regards, Arjun
HTML:
<table id="mytable" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th><input type="checkbox" name= "check_all" id="check_all"/></th>
<th>Request ID</th>
<th>Request Date</th>
<th>Leave Type</th>
<th>Start Date</th>
<th>End Date</th>
<th>Status</th>
</tr>
</thead>
</table>
Javscript
$("#check_all").click(function () {
$(".checkBoxClass").prop('checked', $(this).prop('checked'));
});
$(".checkBoxClass").change(function(){
if (!$(this).prop("checked")){
$("check_all").prop("checked",false);
$(this).closest('tr').removeClass('row_selected');
}
$(this).closest('tr').addClass('row_selected');
});
function sendval(){
var apprReq = [];
var rejReq = [];
var otable = $('#mytable').DataTable();
var aTrs = otable.rows();
for ( var i=0 ; i<aTrs.length ; i++ )
{
if ( $(aTrs[i]).hasClass('row_selected') )
{
apprReq.push( aTrs.rows().data[i] );
}
rejReq.push( aTrs[i] );
}
console.log(apprReq);
console.log(rejReq);
}