In which event I should update data so changes will be visible?

In which event I should update data so changes will be visible?

MisiuMisiu Posts: 68Questions: 4Answers: 2
edited October 2012 in DataTables 1.9
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/

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Anything in oSettings is considered a private variable and generally shouldn't be used directly. In this case, DataTables doesn't know that you've changed a value, since there is not getter / setter on the property. You need to use fnUpdate to do an update on an individual cell or row.

    Allan
  • MisiuMisiu Posts: 68Questions: 4Answers: 2
    Thanks for response :)
    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.
This discussion has been closed.