Swap rows...
Swap rows...
Marcoss1976
Posts: 1Questions: 0Answers: 0
Good afternoon,
The first to congratulate the creator of this marvel of control.
Secondly, I am making a web with 2 tables, only the first has the data loaded. The second will take the data by clicking on the elements of the first table (removed from the first to reach the second)
I've gotten it to work to move items from the first table to the second of the tables, but on the contrary, I did not succeed.
I see some code that could be the fault.
If you know of any examples that you can look to understand how it works.
Here you have the code:
var oTable;
var oTable2;
var giRedraw = false;
$(document).ready(function() {
/* Init DataTables */
oTable = $('#example').dataTable({
"aaData": [[ "Trident", "Internet Explorer 4.0", "Win 95+", 4, "X" ],
[ "Trident", "Internet Explorer 5.0", "Win 95+", 5, "C" ],
[ "Gecko", "Firefox 1.5", "Win 98+ / OSX.2+", 1.8, "A" ],
[ "Gecko", "Firefox 2", "Win 98+ / OSX.2+", 1.8, "A" ],
[ "Gecko", "Firefox 3", "Win 2k+ / OSX.3+", 1.9, "A" ],
[ "Webkit", "Safari 1.2", "OSX.3", 125.5, "A" ],
[ "Webkit", "Safari 3.0", "OSX.4+", 522.1, "A" ]],
"bPaginate": false,"bLengthChange": false,"bFilter": false,"bSort": true,"bInfo": true,"bAutoWidth": true });
oTable2 =$('#example2').dataTable({
"aaData": [],
"bPaginate": false,"bLengthChange": false,"bFilter": false,"bSort": true,"bInfo": true,"bAutoWidth": true } );
$('#example tbody tr').click( function () {
var aPos = oTable.fnGetPosition(this);
var aData = oTable.fnGetData(this);
$('#example2').dataTable().fnAddData(aData);
$('#example').dataTable().fnDeleteRow(aData);
} );
$('#example2 tbody tr').click( function () {
var aPos2 = oTable2.fnGetPosition(this);
var aData2 = oTable2.fnGetData(this);
$('#example').dataTable().fnAddData(aData2);
$('#example2').dataTable().fnDeleteRow(aData2);
} );
} );
Columna 1
Columna 2
Columna 3
Columna 4
Columna 5
Columna 1
Columna 2
Columna 3
Columna 4
Columna 5
Columna 1
Columna 2
Columna 3
Columna 4
Columna 5
Columna 1
Columna 2
Columna 3
Columna 4
Columna 5
The first to congratulate the creator of this marvel of control.
Secondly, I am making a web with 2 tables, only the first has the data loaded. The second will take the data by clicking on the elements of the first table (removed from the first to reach the second)
I've gotten it to work to move items from the first table to the second of the tables, but on the contrary, I did not succeed.
I see some code that could be the fault.
If you know of any examples that you can look to understand how it works.
Here you have the code:
var oTable;
var oTable2;
var giRedraw = false;
$(document).ready(function() {
/* Init DataTables */
oTable = $('#example').dataTable({
"aaData": [[ "Trident", "Internet Explorer 4.0", "Win 95+", 4, "X" ],
[ "Trident", "Internet Explorer 5.0", "Win 95+", 5, "C" ],
[ "Gecko", "Firefox 1.5", "Win 98+ / OSX.2+", 1.8, "A" ],
[ "Gecko", "Firefox 2", "Win 98+ / OSX.2+", 1.8, "A" ],
[ "Gecko", "Firefox 3", "Win 2k+ / OSX.3+", 1.9, "A" ],
[ "Webkit", "Safari 1.2", "OSX.3", 125.5, "A" ],
[ "Webkit", "Safari 3.0", "OSX.4+", 522.1, "A" ]],
"bPaginate": false,"bLengthChange": false,"bFilter": false,"bSort": true,"bInfo": true,"bAutoWidth": true });
oTable2 =$('#example2').dataTable({
"aaData": [],
"bPaginate": false,"bLengthChange": false,"bFilter": false,"bSort": true,"bInfo": true,"bAutoWidth": true } );
$('#example tbody tr').click( function () {
var aPos = oTable.fnGetPosition(this);
var aData = oTable.fnGetData(this);
$('#example2').dataTable().fnAddData(aData);
$('#example').dataTable().fnDeleteRow(aData);
} );
$('#example2 tbody tr').click( function () {
var aPos2 = oTable2.fnGetPosition(this);
var aData2 = oTable2.fnGetData(this);
$('#example').dataTable().fnAddData(aData2);
$('#example2').dataTable().fnDeleteRow(aData2);
} );
} );
Columna 1
Columna 2
Columna 3
Columna 4
Columna 5
Columna 1
Columna 2
Columna 3
Columna 4
Columna 5
Columna 1
Columna 2
Columna 3
Columna 4
Columna 5
Columna 1
Columna 2
Columna 3
Columna 4
Columna 5
This discussion has been closed.