fnDeleteRow callback -- how to get the deleted row's data?
fnDeleteRow callback -- how to get the deleted row's data?
I am able to delete a row just fine, but I need to do some other stuff with the data from that row. The callback from fnDeleteRow does have an object that resembles the deleted row in the second argument, I discovered, but how to handle that one?
[code]
function removeFromCart(node)
{
item = $(node).parents('tr');
itemName = item.find('td')[0];
itemName = $(itemName).html();
if(confirm("Are you sure you want to delete '"+itemName+"' from your cart?"))
{
basket.fnDeleteRow(item, onRowDeleted);
}
}
function onRowDeleted(dataTable, affectedRow)
{
console.log(affectedRow);
ueid = affectedRow._aData[0];
deleteFormData(ueid);
}
[/code]
As you can see I want the data from the first column in the affected row. How to do this? The callback behavior is not really documented on the API page...
[code]
function removeFromCart(node)
{
item = $(node).parents('tr');
itemName = item.find('td')[0];
itemName = $(itemName).html();
if(confirm("Are you sure you want to delete '"+itemName+"' from your cart?"))
{
basket.fnDeleteRow(item, onRowDeleted);
}
}
function onRowDeleted(dataTable, affectedRow)
{
console.log(affectedRow);
ueid = affectedRow._aData[0];
deleteFormData(ueid);
}
[/code]
As you can see I want the data from the first column in the affected row. How to do this? The callback behavior is not really documented on the API page...
This discussion has been closed.
Replies
if you know the row number to delete, you can use that row number to get the node or data
fnGetNode(iRowNumber) or fnGetData(fnGetNode(iRowNumber))
[code]
basket.fnDeleteRow(item, onRowDeleted(ueid));
[/code]
Or something... So how would I do that?
Now I want to access the data in that deleted (affected) row once more, to delete a form element in the page that has the idea with the same name as the value of column 0 (first column, hidden) of the deleted row. So my question now is: how do I use the affectedRow node that is defined in onRowDeleted()? How do I access its data?
An alternative would be to store the data array in a variable with enough scope to be accessed from both the callback and the local function.
Allan