problem in restoring rows after fnDeleteRow
problem in restoring rows after fnDeleteRow
paolo_marcatili
Posts: 2Questions: 0Answers: 0
Hi everyone,
I have setup a table in which rows can be deleted by clicking on an icon present in the row itself. I would like to implement a function to "undelete" such rows. I have tried following http://datatables.net/forums/discussion/comment/2386 but without any luck. My relevant code is this:
[code]
$('#reset').click(function() {
if(delArr.length > 0) {
var oSettings = pT.fnSettings();
for(i=0; i
I have setup a table in which rows can be deleted by clicking on an icon present in the row itself. I would like to implement a function to "undelete" such rows. I have tried following http://datatables.net/forums/discussion/comment/2386 but without any luck. My relevant code is this:
[code]
$('#reset').click(function() {
if(delArr.length > 0) {
var oSettings = pT.fnSettings();
for(i=0; i
This discussion has been closed.
Replies
The way I would approach an undelete is using fnGetData before fnDeleteRow to get the data for the row and store it somewhere. Then, as you say, use fnAddData to add it back in if needed.
Allan
This was exactly my guess, but the only relevant thread I found was the one I linked in which the aiDisplayMaster was the final solution :)
In the end i solved using fnAddData, the problem I was having with the fnAddData is that, once "undeleted", it looks like I can't delete the rows anymore. Updating from the click( function to a live object solved this problem, so in case anyone needs this is my code
[code]
$('#reset').click(function() {
if(delArr.length > 0) {
pT.fnAddData(delArr.pop());
pT.fnDraw();}
}
});
$(".delete").live("click", function () {
delArr.push(pT.fnGetData(pT.fnGetPosition(this.parentNode.parentNode)));
pT.fnDeleteRow(pT.fnGetPosition(this.parentNode.parentNode),null,true);
} );
[/code]
Thank you again for your help and the incredible job you do with datatables!