Reputation: 28314
I am getting the value of checkbox by doing this
$('input:checked', oTable.fnGetNodes()).each(function(i){
console.log(this);
});
it gives me
<input type="checkbox" class="datatableCheckbox">
but how do I get the other values in the other columns of data table in same row??
thanks
Upvotes: 1
Views: 7347
Reputation: 79830
how do I get the other values in the other columns of data table in same row??
Assuming you are dealing with a HTML table, then you can simply get the closest tr
and find the respective td
's
$('input:checked', oTable.fnGetNodes()).each(function(i){
console.log($(this)
.closest('tr') //get the enclosing tr
.find('td:eq(1)')); //find any using td:eq(<index>)
});
Upvotes: 2
Reputation: 55750
Try this
$(oTable.fnGetNodes()).find('td').each(function(i){
console.log(this); // This will give you the td for each row..
});
Assuming oTable.fnGetNodes()
returns the tr's in the table
Upvotes: 0
Reputation: 35193
Try this inside your loop:
$(this).closest('tr').find('input[type="checkbox"]').each(function(i, checkbox){
console.log($(checkbox).val());
});
Or if you want values from all form elements:
$(this).closest('tr').find(':input').each(function(i, input){
console.log($(input).val());
});
Upvotes: 0