Transfering rows to/from tables; index preservation?
Transfering rows to/from tables; index preservation?
smader
Posts: 21Questions: 6Answers: 0
Hi all,
Rank beginner here. I have two tables and I would like to transfer rows between then. The code below does this, mostly...
Say I click on the first row of availTable and transfer it to execTable, okay that is fine. However, should I want to transfer the row in execTable back to availTable, the "Field" name is duplicated! This seems to be an indexing issue, since when I transfer the first row (index 0) from availTable to execTable, it has index 0 in the latter. When I transfer that back to availTable, it takes on values for the existing index. I hope this makes sense. I'm not sure how to address it. Any suggestions?
Using DataTables 1.9.4.
[code]
$(document).ready(function() {
availTable = $('#available').dataTable( {
"bProcessing": true,
"bAutoWidth": true,
"aaData": [
[ "BETA", "F1" ],
[ "BETA", "F2" ],
[ "BETA", "F3" ],
[ "BETA", "F4" ]
],
"aoColumns": [
{ "sTitle": "Project" },
{ "sTitle": "Field" },
]
});
execTable = $('#execute').dataTable({
"bProcessing": true,
"bAutoWidth": true,
"aaData": [ ],
"aoColumns": [
{ "sTitle": "Project" },
{ "sTitle": "Field" },
]
});
availTable.on('click','tr',function() {
var data = availTable.fnGetData(this);
execTable.fnAddData(data);
availTable.fnDeleteRow(this);
});
execTable.on('click','tr',function() {
var data = availTable.fnGetData(this);
availTable.fnAddData(data);
execTable.fnDeleteRow(this);
});
});
[/code]
Rank beginner here. I have two tables and I would like to transfer rows between then. The code below does this, mostly...
Say I click on the first row of availTable and transfer it to execTable, okay that is fine. However, should I want to transfer the row in execTable back to availTable, the "Field" name is duplicated! This seems to be an indexing issue, since when I transfer the first row (index 0) from availTable to execTable, it has index 0 in the latter. When I transfer that back to availTable, it takes on values for the existing index. I hope this makes sense. I'm not sure how to address it. Any suggestions?
Using DataTables 1.9.4.
[code]
$(document).ready(function() {
availTable = $('#available').dataTable( {
"bProcessing": true,
"bAutoWidth": true,
"aaData": [
[ "BETA", "F1" ],
[ "BETA", "F2" ],
[ "BETA", "F3" ],
[ "BETA", "F4" ]
],
"aoColumns": [
{ "sTitle": "Project" },
{ "sTitle": "Field" },
]
});
execTable = $('#execute').dataTable({
"bProcessing": true,
"bAutoWidth": true,
"aaData": [ ],
"aoColumns": [
{ "sTitle": "Project" },
{ "sTitle": "Field" },
]
});
availTable.on('click','tr',function() {
var data = availTable.fnGetData(this);
execTable.fnAddData(data);
availTable.fnDeleteRow(this);
});
execTable.on('click','tr',function() {
var data = availTable.fnGetData(this);
availTable.fnAddData(data);
execTable.fnDeleteRow(this);
});
});
[/code]
This discussion has been closed.
Replies
Allan
Allan