Moving rows between tables, index fail?

Moving rows between tables, index fail?

detratedetrate Posts: 2Questions: 0Answers: 0
edited May 2011 in General
I'm tryinng to move rows between tables and there's some weird behavior going on. I think it has to do with datatable's index and the fnDeleteRow function. I've tried both the latest stable 1.7 and 1.8 beta without success. I'm not sure how to circumvent this issue.

Interactive example and code:

http://jsbin.com/irotu3
http://jsbin.com/irotu3/edit

[code] list1 = $('#list1').dataTable({
"aaSorting": [[ 0, "asc" ]],
"fnRowCallback": function( nRow, aData, iDisplayIndex, iRealIndex ) {
$('td:eq(3)', nRow, '#list1').attr('onclick','').unbind('click'); // callback tries to reinitialize?
$('td:eq(3)', nRow, '#list1').click(function() {
list2.fnAddData([
aData[0],
aData[1],
aData[2],
aData[3]
]);
list1.fnDeleteRow( iRealIndex );
});
return nRow;
},
"bRetrieve ": false
});
list2 = $('#list2').dataTable({
"aaSorting": [[ 0, "asc" ]],
"fnRowCallback": function( nRow, aData, iDisplayIndex, iRealIndex ) {
$('td:eq(3)', nRow, '#list2').attr('onclick','').unbind('click'); // callback tries to reinitialize?
$('td:eq(3)', nRow, '#list2').click(function() {
list1.fnAddData([
aData[0],
aData[1],
aData[2],
aData[3]
]);
list2.fnDeleteRow( iRealIndex );
});
return nRow;
},
"bRetrieve ": false
});[/code]

I found some older threads that pointed to fnDeleteRow but according to the recent changes in 1.7, their complaints should have been fixed. The callback also seems to reinitalizing the click event... so I don't know if this has anything to do with the issue. Any help is greatly appreciated, this is very frustrating.

Replies

  • detratedetrate Posts: 2Questions: 0Answers: 0
    Using fnGetPosition(this)[0] instead of iRealIndex, I was able to get this working.

    http://jsbin.com/irotu3/2

    I'm still unclear on why the fnRowCallback is initializing rows that haven't changed though.
This discussion has been closed.