problem in restoring rows after fnDeleteRow

problem in restoring rows after fnDeleteRow

paolo_marcatilipaolo_marcatili Posts: 2Questions: 0Answers: 0
edited November 2013 in General
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

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You should _never_ need to use the settings object - those parameters are considered private and may very well change between versions. Also, it looks like you are using that parameter incorrectly (not unreasonably since it isn't well document - which in turn is because its an internal parameter).

    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
  • paolo_marcatilipaolo_marcatili Posts: 2Questions: 0Answers: 0
    edited November 2013
    Hi Allan, thx for the reply!
    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!
This discussion has been closed.