Datatables fnGetData returns two rows for two checkboxes in a row? in fact it is only one row, rte?
Datatables fnGetData returns two rows for two checkboxes in a row? in fact it is only one row, rte?
tinmichael
Posts: 4Questions: 0Answers: 0
$('input:checked ', bookingDetailsDataTable.fnGetNodes()).each(function (index) {
var row = $(this).closest('tr');
alert(index);});
For the above code, I have got the alert twice, first zero and second two. even though I check only one row, but two checkboes. When I check the first checkbox, I have got the correct value. But checking the second checkbox in the same rote, it returns two index value, I think fnGetData thinks that even though there is only one row, since there is two checkboxes in a row, it regards as two rows. Please let me know if there is any extra filter that I need to put when getting the fnGetNodes? I have tried like $('input:checked [name$="cbSomething"] ', bookingDetailsDataTable.fnGetNodes()).each(function (index); }); but not successfult. Your help is much appreciated. Datatables Rocks!!!
var row = $(this).closest('tr');
alert(index);});
For the above code, I have got the alert twice, first zero and second two. even though I check only one row, but two checkboes. When I check the first checkbox, I have got the correct value. But checking the second checkbox in the same rote, it returns two index value, I think fnGetData thinks that even though there is only one row, since there is two checkboxes in a row, it regards as two rows. Please let me know if there is any extra filter that I need to put when getting the fnGetNodes? I have tried like $('input:checked [name$="cbSomething"] ', bookingDetailsDataTable.fnGetNodes()).each(function (index); }); but not successfult. Your help is much appreciated. Datatables Rocks!!!
This discussion has been closed.
Replies
fnGetNodes just gets an array of TR elements, and the jQuery selector runs over that. Perhaps it makes more sense using the newer API:
[code]
bookingDetailsDataTable.$('input:checked').each( function () { ... } );
[/code]
that will still get all checked input boxes, but it should be more obvious what is happening. Sounds to me like you need to make your selector, more selective.
Allan