Deleting a row from the table... table is not empty
Deleting a row from the table... table is not empty
I made two tables transferring row from one data to another by clicking the image
[code]
$(document).ready(function() {
/* Add a click handler to the rows - this could be used as a callback */
$('#searchTable td img.button').click(function(){
var index = $(this).parent().parent().parent().children().index($(this).parent().parent());
var row = sTable .fnGetNodes( index );
sTable.fnDeleteRow( index );
$('#preferTable > tbody:last').append(row);
} );
sTable = $('#searchTable').dataTable( );
pTable = $('#preferTable').dataTable( );
});
[/code]
The my dummy has only two data... the problem is when I delete index 1 then index 0, table is empty which is correct... But when I delete index 0 then index 0, the latest row is not deleted nor transfered...
[code]
$(document).ready(function() {
/* Add a click handler to the rows - this could be used as a callback */
$('#searchTable td img.button').click(function(){
var index = $(this).parent().parent().parent().children().index($(this).parent().parent());
var row = sTable .fnGetNodes( index );
sTable.fnDeleteRow( index );
$('#preferTable > tbody:last').append(row);
} );
sTable = $('#searchTable').dataTable( );
pTable = $('#preferTable').dataTable( );
});
[/code]
The my dummy has only two data... the problem is when I delete index 1 then index 0, table is empty which is correct... But when I delete index 0 then index 0, the latest row is not deleted nor transfered...
This discussion has been closed.
Replies
To make it easier, I'd suggest just passing in the TR element (drop the index stuff). Then use fnGetData, to get the data for that row, and then fnAddData to add it to the other table, and fnDeleteRow on the original table to delete it.
Allan
Tried this... havent tested due to the fact that oSettings.aoData[iRow] is undefined
[code]
$('#searchTable td img.movebut').click(function(){
var row = sTable.fnGetData($(this).parent().parent());
sTable.fnDeleteRow( row ); --> havent tested
pTable.fnAddRow( row ); --> havent tested
} );
[/code]
[code]
$(document).ready(function() {
$('#searchTable td img.movebut').click(function(){
var oRow = $(this).parent().parent();
var row = sTable.fnGetData(oRow[0]);
sTable.fnDeleteRow(row);
$('#preferTable > tbody:last').append(row);
} );
sTable = $('#searchTable').dataTable( );
pTable = $('#preferTable').dataTable( );
});
[/code]
But same thing... Either oSettings.aoData[iRow] or oSettings.aoData[iAODataIndex] is undefined