the row is not deleted from datatable when i remove it from the dom

the row is not deleted from datatable when i remove it from the dom

master55master55 Posts: 5Questions: 0Answers: 0
edited March 2014 in DataTables 1.9
Hi i use datatables 9, and when i remove a row with $('tr[id="'+idProduit+'"]').remove(); because fnDeleteRow($('tr[id="'+idProduit+'"]')) doesn't work, and after removing i search this row in the search input the row is still there, why? i have tried this :

$('.suppBtn').on('click',function(){
var aPos = tblPrdt.fnGetPosition(this);
tblPrdt.fnDeleteRow(aPos); =>doesn't work
}

i have also tried this :
$('tr[id="'+idProduit+'"]').remove(); =>works but the row is already in the table when i search
tblPrdt.fnDeleteRow($('tr[id="'+idProduit+'"]')); he delete the first row all time
also : tblPrdt.fnDeleteRow($('tr[id="'+idProduit+'"]'),null,true); => same problem

help me please, because this is a great plugin, but i had a lot of problems because of this, and the temporary solution that i have is to reload the page but that touch the performance of the application.

Replies

  • master55master55 Posts: 5Questions: 0Answers: 0
    my question is simple : can you give me a simple example to remove a row from datatable ?

    the table are :
    ....


    xx
    33
    Delete

    ....


    when i click on Delete, how can i remove it with fnDeleteRow?
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    Same as this issue here: http://datatables.net/faqs#append

    You must use the API to tell the DataTable that the rows are being updated. It can't know that you have removed an element from the DOM!

    Allan
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    Example: http://live.datatables.net/gumuvod/1/edit
  • master55master55 Posts: 5Questions: 0Answers: 0
    thanks, im going to see what i can do
  • master55master55 Posts: 5Questions: 0Answers: 0
    i have used tableX.fnDeleteRow($('tr[id="'+idPrdt+'"]'),null,true); and it always removes the first row, why?

    the table are :
    ....


    xx
    33
    Delete

    ....
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    We would need a link to the page showing the problem to be able to debug the issue. Can you please provide such a link.

    Allan
  • master55master55 Posts: 5Questions: 0Answers: 0
    Sorry i can't do that, and i understand that you need a real case to debug, finally, i have made a solution that consists on removing the datatable from the dom and appending it after adding, updating or removing a database record, and that works, i load only the datatable instead of loading all the page, it's less performant than removing one row or adding one row, but that's enough for me
    thanks for the support.
This discussion has been closed.