Changing cell data by javascript
Changing cell data by javascript
I have the current function
function setcoldata(tab,row,col,data){
$('#'+tab+' tr:nth-child('+row+') td:nth-child('+col+')').html(data);
}
It works but if one more row before the targeted row is displaying a child row then the actual targeted row should be incremented.
Example:
Row 1
--Child Row
Row 2
I want to change the first column of row2
setcoldata('mytable';2;1;'data') will not work because the row #2 is actually the the information child row.
Not exactly sure how to proceeed.
Counting the child rows before the targeted row ?
Or is there a way to omit certain classes when using nth-child ?
I'm still a beginner in Javascript...
This question has an accepted answers - jump to answer
Answers
Changing the data in the DOM wouldn't be reflected in DataTables - since it caches its data. It would be best to use
cell().data()
orrow().data()
to change the data.Colin
Thanks. Got it to work with cell().data.