delete operation redraws table but changes current 'page'

delete operation redraws table but changes current 'page'

readyleereadylee Posts: 6Questions: 0Answers: 0
edited May 2011 in Bug reports
I am using DataTables 1.7.6. When I attempt to implement the fnDeleteRow function, the (selected) record is indeed removed from the table....and the table is redrawn...but at that point it displays the PREVIOUS page. So if I'm on page 3 of the table when I request the delete operation, I end up on page 2 of the table.
I have the following function for deleting a row from the table:
[code]
function fnDeleteRowDT(){
var dSelected = [];
var aNodes = oTable.fnGetNodes();
for (var i=0; i

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    On this page - http://datatables.net/examples/basic_init/zero_config.html - if I go to page 3 and then run:

    [code]
    $('#example').dataTable().fnDeleteRow($('#example tbody tr')[0]);
    [/code]

    to delete that first row - it stays on the same page for me. It seems to work regardless of which page I put it on. Can you link us to your example please?

    Allan
  • readyleereadylee Posts: 6Questions: 0Answers: 0
    I think I've solved the problem. For clarity and simplicity, previously I failed to mention that I needed to make an ajax request to the server in order to delete the ACTUAL data record from the DB.
    So instead of calling fnDeleteRow from my fnDeleteRowDT function, I simply call fnDraw(false) after the ajax request completes. This is actually better, since I need it to be an actual DB deletion anyway. I had tried to resolve it this way before, but it seems I had to experiment with the timing of my fnDraw call before I was able to achieve consistent behavior...
This discussion has been closed.