Calling fnGetData after fnDeleteRow(..., ..., true) returns data including deleted row.
Calling fnGetData after fnDeleteRow(..., ..., true) returns data including deleted row.
I have a table that I'm wanting to dynamically add and delete rows from. The first column contains a row number where the first row (not header) in column 1 would have a 1 in it. Whenever I delete the selected row I want to renumber all the rows.
I am using the following code to delete a row:
[code]
var anSelected = fnGetSelected(oTable);
if (anSelected.length > 0) {
oTable.fnDeleteRow(anSelected[0], renumberLayers, true);
}
[/code]
This is called when the delete button is pressed. The following is my code for layerDeleted:
[code]
function renumberLayers() {
var tableData = oTable.fnGetData();
for (var i = 0; i < tableData.length; i++) {
oTable.fnUpdate(i + 1, i, 0);
}
}
[/code]
The problem is that if the table has two rows and I click to delete one tableData.length always returns 2 with the data for the table as it was before deleting the row.
I'm also a little worried about a bug I found while searching the forums:
http://datatables.net/forums/comments.php?DiscussionID=1636&page=1#Item_0
Is that bug going to prevent me from adding rows after deleting?
Thanks.
I am using the following code to delete a row:
[code]
var anSelected = fnGetSelected(oTable);
if (anSelected.length > 0) {
oTable.fnDeleteRow(anSelected[0], renumberLayers, true);
}
[/code]
This is called when the delete button is pressed. The following is my code for layerDeleted:
[code]
function renumberLayers() {
var tableData = oTable.fnGetData();
for (var i = 0; i < tableData.length; i++) {
oTable.fnUpdate(i + 1, i, 0);
}
}
[/code]
The problem is that if the table has two rows and I click to delete one tableData.length always returns 2 with the data for the table as it was before deleting the row.
I'm also a little worried about a bug I found while searching the forums:
http://datatables.net/forums/comments.php?DiscussionID=1636&page=1#Item_0
Is that bug going to prevent me from adding rows after deleting?
Thanks.
This discussion has been closed.
Replies
Allan