In which event I should update data so changes will be visible?
In which event I should update data so changes will be visible?
Misiu
Posts: 68Questions: 4Answers: 2
I'm building a 2 tables page that will allow moving rows from one table to another.
In my first table I have column called "percentage" that shows value of column one divided by sum of whole first column.
I'm calculating my nem data in "fnPreDrawCallback":
[code]
"fnPreDrawCallback": function (oSettings) {
iTotal = [0, 0, 0];
var dataLength=oSettings.aoData.length;
for (var i = 0; i < dataLength; i++) {
iTotal[0] += oSettings.aoData[i]._aData.salary;
iTotal[1] += oSettings.aoData[i]._aData.bonus1;
iTotal[2] += oSettings.aoData[i]._aData.bonus2;
}
for (i = 0; i < dataLength; i++) {
oSettings.aoData[i]._aData.percent=(oSettings.aoData[i]._aData.salary / iTotal[0] * 100).toFixed(2)+'%';
}
console.log(oSettings.aoData);
},
[/code]
In console I can see that data is correctly updated, but updates aren't visible.
In which event I should update my data so that updates will be visible in table?
Here is my demo: http://live.datatables.net/umezez/15/
In my first table I have column called "percentage" that shows value of column one divided by sum of whole first column.
I'm calculating my nem data in "fnPreDrawCallback":
[code]
"fnPreDrawCallback": function (oSettings) {
iTotal = [0, 0, 0];
var dataLength=oSettings.aoData.length;
for (var i = 0; i < dataLength; i++) {
iTotal[0] += oSettings.aoData[i]._aData.salary;
iTotal[1] += oSettings.aoData[i]._aData.bonus1;
iTotal[2] += oSettings.aoData[i]._aData.bonus2;
}
for (i = 0; i < dataLength; i++) {
oSettings.aoData[i]._aData.percent=(oSettings.aoData[i]._aData.salary / iTotal[0] * 100).toFixed(2)+'%';
}
console.log(oSettings.aoData);
},
[/code]
In console I can see that data is correctly updated, but updates aren't visible.
In which event I should update my data so that updates will be visible in table?
Here is my demo: http://live.datatables.net/umezez/15/
This discussion has been closed.
Replies
Allan
But can I call fnUpdate multiple times inside fnPreDrawCallback (for each row in my table)?
Or where I should/must call fnUpdate?
I use fnAddData to move rows between tables.
I know that I can modify dom of table, but I would prefer to modify data, because then I'll be able to export it without any problem.