fnDeleteRow using tr element

fnDeleteRow using tr element

sparhsparh Posts: 11Questions: 2Answers: 0
edited December 2012 in DataTables 1.9
Hi,
in http://www.datatables.net/ref#fnDeleteRow it is written
"{mixed}: The index of the row from aoData to be deleted, or the TR element you want to delete";

The tr id I want to delete is 2 (...)
I have tried without any success :
$("#delete").click(function() {
oTable.fnDeleteRow(2);
// or oTable.fnDeleteRow($("#2"));
});

Thanks

Replies

  • allanallan Posts: 63,391Questions: 1Answers: 10,450 Site admin
    Should work okay. Can you link to a test case showing the problem live and not working please?
    http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Allan
  • sparhsparh Posts: 11Questions: 2Answers: 0
    Here is a test case : http://live.datatables.net/azemaw/7/edit

    There is one row that have

    My delete button is :
    $("#delete").click(function() {
    oTable.fnDeleteRow(5);
    });

    It deletes a row but not the one with id="5" (I have also tested oTable.fnDeleteRow($("#5")); and the result is the same, it deletes a row but not the right one)

    Thanks
  • allanallan Posts: 63,391Questions: 1Answers: 10,450 Site admin
    Works okay if you pass in the node: http://live.datatables.net/azemaw/8/edit

    Allan
  • sparhsparh Posts: 11Questions: 2Answers: 0
    Ok many thanks Allan, oTable.fnDeleteRow( $('#5')[0] ); works well.

    is there a way to delete many rows in one time (For example I want to delete ids 5, 10, 15 45)?
  • allanallan Posts: 63,391Questions: 1Answers: 10,450 Site admin
    Currently no - I'll be introducing that into 1.10 where you will be able to delete multiple rows by passing in a jQuery object. In 1.9- it requires a loop.

    Allan
  • sparhsparh Posts: 11Questions: 2Answers: 0
    Many thanks for the help.
This discussion has been closed.