rows().data() vs cell().data()
rows().data() vs cell().data()
Is rows().data()
returning the values from DataTables internal cache while cell().data()
is returning the value of the DOM's TD innerHTML
?
I'm trying to understand why rows().date()
returns NULLs for the cell's value while cell().data()
returns an empty string.
I'm initializing a table with empty rows by calling this within a loop:
table.row.add({"idx" : null, "field1": null, "field2": null});
And I'm making the api calls this way, immediately after initializing the table:
console.log(table.rows().data());
console.log(table.cell(2, 2).data());
The column's defaultContent
option for both "field1" and "field2" is an empty string, so I think I understand the value returned by cell().data()
. My question really is why the 2 api calls don't return the same value for the same cell?
EDIT
Further, a call to table.rows().draw();
does not sync the values up.
This question has an accepted answers - jump to answer
Answers
No - they both return the internal cache value. Or at least they should!
Could you link to a test page showing the issue so I can debug it please?
Allan
Allan, thanks for the prompt reply. I'll double check what I'm saying and put together a sample project to demonstrate this, assuming I've not made an error, and send it your way.
This is interesting, because
cell().data()
is documented this way:....
So, the two forms of
cell()
method, reads from and writes to different locations?Hi,
We discussed this by e-mail, but for anyone else who encounters this, there are a couple of issues here:
cell().data()
should return the plain data from the data source object/array. Currently if that isnull
andcolumns.defaultContent
is given, it will return the default content. That is wrong and has been fixed.Allan