row remove and toData

row remove and toData

optoopto Posts: 5Questions: 2Answers: 0

my data comes from an array.
I remove rows, they disappear from the table, but they stay in table.toData().

What am I doing wrong?

All by adding a button in each row and on click:
$this = $(this);
var dtRow = $this.parents('tr');
var table1 = $('#example1').DataTable();
table1.row(dtRow[0].rowIndex-1).remove().draw( false );

any help is appreciated,

Klaus

Answers

  • kthorngrenkthorngren Posts: 14,117Questions: 25Answers: 3,328

    they disappear from the table, but they stay in table.toData().

    What is toData()? As far as I know this is not a Datatables method or API.

    Please post a line to your page or a test case showing the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • optoopto Posts: 5Questions: 2Answers: 0

    I am sorry, this is what I meant: table.data().toArray();

    the array is not identical to the table that is visible. Thus, I was wondering what remove does: actually remove the nodes, or just make them invisible?

  • sandysandy Posts: 705Questions: 0Answers: 194

    Hi @opto ,

    The docs for row().remove() state the following

    This method (and its plural counterpart, rows().remove()) will remove the selected row from the DataTable completely, deleting the allocated memory for data and node from the browser.

    I've put together an example for you to show this working. Could you modify this to show your issue?

    Thanks,
    Sandy

Sign In or Register to comment.