Deleting rows that are not on page

Deleting rows that are not on page

martingaymartingay Posts: 2Questions: 0Answers: 0
edited July 2013 in General
I am attempting to remove a row using the fnGetPosition and fnDeleteRow. I am using the pagination feature. The row I wish to delete is not currently being display as it is on another page. e.g. I am showing 1-10 entries, where I want to delete the 23rd entry.

fnGetPosition fails (as you would expect). However, I need a way to remove the entry from the underlying data. Is this possible?

Replies

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    Perhaps:

    [code]
    var row = table.$('#myRowId')[0];
    table.fnDeleteRow( row );
    [/code]

    ?

    DataTables 1.10 will be able to do:

    [code]
    table.row( '#myRowId' ).remove().draw();
    [/code]

    Allan
  • martingaymartingay Posts: 2Questions: 0Answers: 0
    Thanks for the reply. I do not believe those attempts will work for me as the row are not being shown (on a different page) and therefore not in the dom / document.

    I need to delete the row, such that if the user uses the pagination options, then the 23rd entry has been deleted. Essentially I want to update the underlying data structures and ensure the total count has been decremented on the UI.
  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    They will work for you regardless of paging and filtering. That's the whole point of the `$` method of DataTables (not it is not jQuery - it is the DataTables proxy to jQuery) and the `row()` methods.

    Allan
This discussion has been closed.