After fnDeleteRow , fnUpdateRow wont work. _aData of undefined error
After fnDeleteRow , fnUpdateRow wont work. _aData of undefined error
Whitecastle
Posts: 2Questions: 0Answers: 0
My simple table initialization:
[code]
oTable = $('#mytable').dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"oLanguage": {
"sUrl": "pt_PT.txt"
}
});
[/code]
How do i add a row:
[code]
function fnClickAddRow(JSON) {
var sdate = convertDate(JSON.start,"yyyy-MM-dd");
var edate = convertDate(JSON.end,"yyyy-MM-dd");
var removebutton = 'Remove row'; //numberOfRows is a global var
var line = numberOfRows;
var newRow = oTable.fnAddData([line,JSON.title,sdate,edate,removebutton]);
var thenode = oTable.fnSettings().aoData[ newRow[0] ].nTr;
thenode.setAttribute('id',numberOfRows); //Here i add a row attribute for example
}
[/code]
How do i remove:
(in this point, before i remove fnUpdate works well )
[code]
function fnRemoveRow(idrow)
{
oTable.fnDeleteRow($('#'+idrow)[0]);
}
[/code]
Removing the rows works well it is removed. Is this the correct way to delete?
How do i update a row:
[code]
function fnUpdateRow(eventToUpdate,di,df){
var line = eventToUpdate.id;
var sdate = convertDate(di,"yyyy-MM-dd");
var edate = convertDate(df,"yyyy-MM-dd");
var removebutton = 'Remove row';
oTable.fnUpdate( [line, eventToUpdate.title, sdate, edate,removebutton], line ); // Row
}
[/code]
The problem is, when i add rows like 10 or more or only one it doesn't matter, fnUpdateRow() allways work well, but when i remove only one row from the 10 rows or the single row,add another row and try to update it gives me the Cannot set property '_aData' of undefined.
[code]
oTable = $('#mytable').dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"oLanguage": {
"sUrl": "pt_PT.txt"
}
});
[/code]
How do i add a row:
[code]
function fnClickAddRow(JSON) {
var sdate = convertDate(JSON.start,"yyyy-MM-dd");
var edate = convertDate(JSON.end,"yyyy-MM-dd");
var removebutton = 'Remove row'; //numberOfRows is a global var
var line = numberOfRows;
var newRow = oTable.fnAddData([line,JSON.title,sdate,edate,removebutton]);
var thenode = oTable.fnSettings().aoData[ newRow[0] ].nTr;
thenode.setAttribute('id',numberOfRows); //Here i add a row attribute for example
}
[/code]
How do i remove:
(in this point, before i remove fnUpdate works well )
[code]
function fnRemoveRow(idrow)
{
oTable.fnDeleteRow($('#'+idrow)[0]);
}
[/code]
Removing the rows works well it is removed. Is this the correct way to delete?
How do i update a row:
[code]
function fnUpdateRow(eventToUpdate,di,df){
var line = eventToUpdate.id;
var sdate = convertDate(di,"yyyy-MM-dd");
var edate = convertDate(df,"yyyy-MM-dd");
var removebutton = 'Remove row';
oTable.fnUpdate( [line, eventToUpdate.title, sdate, edate,removebutton], line ); // Row
}
[/code]
The problem is, when i add rows like 10 or more or only one it doesn't matter, fnUpdateRow() allways work well, but when i remove only one row from the 10 rows or the single row,add another row and try to update it gives me the Cannot set property '_aData' of undefined.
This discussion has been closed.
Replies
Meanwhile if someone could be so kind and try to see the problem i would be very apreciated.
Thank you