[v1.9] Updating object returned by fnGetData() to update table data

[v1.9] Updating object returned by fnGetData() to update table data

errorerror Posts: 2Questions: 2Answers: 0

I am using DataTables to display some objects. At the moment, I am doing the following to update the attribute attr in a row:

    var data = DT.fnGetData(tr);
    data.attr = val;
    DT.fnUpdate(data, tr);

This works, but seems quite inelegant. Instead, I think I can just modify the object directly:

    DT.fnGetData(tr).attr = val;
    DT.fnDraw();

This code should work as well, as long as the object returned by fnGetData is a direct reference to the internal object (and not a copy).

Can anybody confirm whether this will work, or whether this is a bad idea? Is there a better way of doing this?

This discussion has been closed.