Upgraded to DataTables 1.7.2 - fnDeleteRow still throws error when first row is deleted
Upgraded to DataTables 1.7.2 - fnDeleteRow still throws error when first row is deleted
PaoloValladolid
Posts: 35Questions: 0Answers: 0
The error is thrown only when the first row is selected, but it doesn't happen all the time. here is the error:
Line: 1754
Error: 'aoData[...].nTr' is null or not an object
Here is the function calling fnDeleteRow:
[code]
function deleteIngredients() {
var numRows = ingredientsTable.fnGetData().length;
var isAtLeastOneRowSelected = false;
for (var i=0; i < numRows; i++) {
var node = ingredientsTable.fnGetNodes(i);
if ($(node).hasClass('row_selected')) {
isAtLeastOneRowSelected = true;
var currentData = ingredientsTable.fnGetData(i);
if (confirm("Are you sure you want to delete Ingredient " + currentData[1] + "?"))
{
ingredientsTable.fnDeleteRow(node,null,true);
}
}
}
if (!isAtLeastOneRowSelected)
{
alert("No ingredient was selected.");
}
}
[/code]
* Edited by Allan to add code highlighting (make life easier :-) )
Line: 1754
Error: 'aoData[...].nTr' is null or not an object
Here is the function calling fnDeleteRow:
[code]
function deleteIngredients() {
var numRows = ingredientsTable.fnGetData().length;
var isAtLeastOneRowSelected = false;
for (var i=0; i < numRows; i++) {
var node = ingredientsTable.fnGetNodes(i);
if ($(node).hasClass('row_selected')) {
isAtLeastOneRowSelected = true;
var currentData = ingredientsTable.fnGetData(i);
if (confirm("Are you sure you want to delete Ingredient " + currentData[1] + "?"))
{
ingredientsTable.fnDeleteRow(node,null,true);
}
}
}
if (!isAtLeastOneRowSelected)
{
alert("No ingredient was selected.");
}
}
[/code]
* Edited by Allan to add code highlighting (make life easier :-) )
This discussion has been closed.
Replies
return oSettings.aoData[iRow].nTr;
In this particular instance, aoData has 3 elements, and iRow=3, which is a problem because aoData[2] is the third element and thus there is no aoData[3].
I'm willing to hack a fix for this at this point, if someone can give me some guidance on a way to do it without breaking Datatables. We really need to get this to work asap.
Allan
Line: 1734
Error: 'aoData[...]._aData' is null or not an object
Here is the code:
$('#ingredientsTable tr.row_selected').each(function(index) {
isAtLeastOneRowSelected = true;
var currentData = ingredientsTable.fnGetData($(this));
if (confirm("Are you sure you want to delete Ingredient " + currentData[1] + "?"))
{
ingredientsTable.fnDeleteRow($(this),null,true);
}
});
I'll keep trying...
$('#ingredientsTable tr.row_selected').each(function(index) {
isAtLeastOneRowSelected = true;
alert('line ' + index);
var currentData = ingredientsTable.fnGetData(index);
if (confirm("Are you sure you want to delete Ingredient " + currentData[1] + "?"))
{
ingredientsTable.fnDeleteRow(index,null,true);
}
});
Changed $(this) to index