Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81992

fnUpdate in 1.9.4: consistency issue when adding objects

$
0
0
I see a consistency problem with fnUpdate regarding using an object to update the entire row. The code is specifically checking for a 'plain' object, created anonymously, or with new Object. The problem is this same requirement is not enforced when the table is first created.

I have created a custom class (we'll call it FooClass). I create an array of foos and set aaData to this array on init.
foos = [];
...
foo = new FooClass();
...
foos.push(foo);

$dataTable = $('#container').dataTable({aaData: foos, ...});
This works nicely.

Later, I edit the foo and want to replace the foo object in the row using fnUpdate.

rowElem = (a tr node in the #container table);

foo = new FooClass({name: 'someName'});
$dataTable.fnUpdate(foo, rowElem);
This fails, because foo does not pass the $.isPlainObject() test on line 6159:

6159: else if ( $.isPlainObject(mData) && iColumn === undefined )

The underlying issue is that this check for isPlainObject is not performed initially.
My choice would be to allow any object to be used in fnUpdate, not not restrict them to anonymous objects with no prototype.

John Gillespie

Viewing all articles
Browse latest Browse all 81992

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>