Issue with programmatic change row information
Issue with programmatic change row information
scsbreese
Posts: 8Questions: 2Answers: 0
The documentation indicates that data and add both take a JS array or object.
However, row().data($data) fails if the object is of HTMLTableRow type.
row.add($data) works regardless of the type.
For instance, this works:
$html = $.parseHTML($.trim(html));
$dRow = dataTable.row.add($html);
$data = $dRow.data();
$dRow.remove();
dataTable.row($rowIndex).data($data).draw();
While this fails:
$html = $.parseHTML($.trim(html));
dataTable.row($rowIndex).data($html).draw();
This question has accepted answers - jump to:
This discussion has been closed.
Answers
It seems to work okay here when giving it an HTML row: http://live.datatables.net/haqotuhe/1/edit .
Can you link to a test case showing the issue please?
Allan
Sure, the issue is not with the add function but with the data function:
http://live.datatables.net/jadakoxe/2/edit
Oh I see - but the
row().data()
method won't accept a node - at least there is nothing in the documentation to suggest that it will (if there is, please let me know where so I can remove it).The
row().data()
method will accept an object (as in a plain Javascript object), or an array of data - matching the data structure that has already been used for that row.Allan
Nothing in the documentation for
row().data()
indicates that it won't accept a node either and it has the same parameter descriptions asrow.add()
which would indicate that if the add accepts a node, the data should also.The description of the set data parameter for each function is identical, therefore, I think I should expect them to behave in the same way.
Ultimately, I found a way around it (as is shown in my first post) but was confused as to why both functions required a different object of data.
Good point - thank you! The
row.add()
documentation is incomplete. I will fix that shortly.Good to hear that you got a workaround!
Allan
Thanks for your help and your great work on this plugin.
I've just added a little bit more information to the documentation. It will be deployed to the site in the next update.
I think I can improve on the documentation beyond this - I've got a note to spend a little time on those two methods!
Allan