Change cells value in Datatables in selected rows only
Change cells value in Datatables in selected rows only
I m trying to target some cells values only in selected row or rows. I have tried a code as explained in the following snippets but it keeps targeting the first row, not the selected one,
$("#btn1").click(function() {
var rows_selected = tablenest.rows({
selected: true
});
$.each(rows_selected, function(i, v) {
tablenest.row(rows_selected).cell(':eq(3)').data("").draw();
tablenest.row(rows_selected).cell(':eq(4)').data("").draw()
});
return false;
})
i have live ex here
Answers
bingo
tablenest.rows({ selected: true }).every(function (rowIdx, tableLoop, rowLoop) {
tablenest.row(this).cell(rowIdx,2).data("").draw()
tablenest.row(this).cell(rowIdx, 3).data("").draw()
});
Almost perfect. I would suggest:
as a slight modification. It will run faster
Allan