AddData and DeleteData
AddData and DeleteData
first of all, excuse for my English. I have read all topics with 'DeleteData', but I have a problem. I have 2 tables, and from one I post data to another, for example I have a row(from table 1) and post it by
fnClickAddRow=function(data)
{
oTableDataRemarksConclusionList.fnAddData([
data['date'],
data['problem'],
data['info'],
data['status']]
);
}
to another table
then I have in my second table a link to delete this row from the second table:
var anSelected = fnGetSelected(oTableDataRemarksConclusionList,remark_id,key);
var iRow = oTableDataRemarksConclusionList.fnGetPosition(anSelected[0]);
oTableDataRemarksConclusionList.fnDeleteRow(iRow);
It's almost the same as in 'Api Delete', but if I want to add the same row(that I have already deleted) from the first table, it's ok, but this row in the second table has Index, the same, as the row I have already deleted, and if I want to delete this row again(the second time) , it's not ok.
I think that the problem in cashe, so if I do
oSettings = oTableDataRemarksConclusionList.fnSettings();
var iLen = oSettings.aoData[iRow]._aData;
alert(iLen);
I have the data from my deleted row. so, how I can delete this row finally from the Dom? or how I can add row, then delete this row, and again add this row, but with anothr Index?
fnClickAddRow=function(data)
{
oTableDataRemarksConclusionList.fnAddData([
data['date'],
data['problem'],
data['info'],
data['status']]
);
}
to another table
then I have in my second table a link to delete this row from the second table:
var anSelected = fnGetSelected(oTableDataRemarksConclusionList,remark_id,key);
var iRow = oTableDataRemarksConclusionList.fnGetPosition(anSelected[0]);
oTableDataRemarksConclusionList.fnDeleteRow(iRow);
It's almost the same as in 'Api Delete', but if I want to add the same row(that I have already deleted) from the first table, it's ok, but this row in the second table has Index, the same, as the row I have already deleted, and if I want to delete this row again(the second time) , it's not ok.
I think that the problem in cashe, so if I do
oSettings = oTableDataRemarksConclusionList.fnSettings();
var iLen = oSettings.aoData[iRow]._aData;
alert(iLen);
I have the data from my deleted row. so, how I can delete this row finally from the Dom? or how I can add row, then delete this row, and again add this row, but with anothr Index?
This discussion has been closed.
Replies
1. When you call fnDeleteRow() it doesn't actually delete the data from aoData - it just removes it from aiDisplay and aiDisplayMaster (internal DataTables variables) and as such it is possible that something is matching there. To over come this it might be best to set the deleted row (in aoData) to null. I'm thinking about making this the default action - but not quite decided yet!).
2. Might fnGetSelected() be caching something? How does this function work?
Thanks,
Allan
1.yes,I think it is the problem. but, when I add and delete the row first time, it removes it from aiDisplay and aiDisplayMaster, but not from aoData. ant then, when I add and delete the same row, it doesn't remove ???? from display, and then if I want to add and delete the sam? row again, it makes copies of this row in aiDisplay.
so, I think the solution is to call fnDeleteRow() and delete this row from aoData the same time.
so,
var anSelected = fnGetSelected(oTableDataRemarksConclusionList,remark_id,key);
var iRow = oTableDataRemarksConclusionList.fnGetPosition(anSelected[0]);
oTableDataRemarksConclusionList.fnDeleteRow(iRow);
oSettings = oTableDataRemarksConclusionList.fnSettings();
oSettings.aoData[iRow]._aData=null; ?! is it right?
alert(oTableDataRemarksConclusionList.fnGetData());
because when I do it firstly It's all right and there is no this row in in aiDisplay. and when I call alert(oTableDataRemarksConclusionList.fnGetData());, it doen't show my row.
but the second time I add this row, and when I delete, there is an error: (oSettings.aoData[iAODataIndex]._aData is null) and it calls an exception
2.fnGetSelected=function(oTableLocal,remark_id,key)
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();
for ( var i=0 ; i
Regarding making the delete row function set aoData[i] to null, the reason not to do this is that the current method provides a lot of flexibility with regard to restoring rows if the developer wanted to do this for whatever application - plus the majority of interactions with the core data should be with aiDisplay and aiDisplayMaster and the indexes that they point to in aoData.
Allan