I m trying to drag n drop rows between two tables. First table has 3 columns and the second table has 4 columns. I have the drag n drop working.
All the examples I have seen generally appendTo at the dropped location. What I would like to do is replace the contents of the dragged row and replace/update the cells in the dropped location.
I was thinking if I can maybe write a new tablerow( ..) and then remove the current dropped row and replace it with the generated row. Or maybe just update the columns in the new location.
(function ($) {
$(document).ready(function () {
var tb1 = $("#table1 tr");
var tb2 = $("#table2 tr");
tb1.draggable({
appendTo: "body",
helper: "clone",
opacity: "0.35",
revert: "invalid"
});
tb2.droppable({
accept: '#table1 tr',
tolerance: "pointer",
drop: function (event, ui) {
//loop through all items in the row
var $col1, $col2;
tb1.each(function () {
$col1 = $("span:eq(0)", this).text();
$col2 = $("span:eq(1)", this).text();
});
$droppedRow = $(this).children('td');
var $destCol1 = $droppedRow.find('span')[0].innerHTML;
var $destCol2 = $droppedRow.find('span')[1].innerHTML;
var $row = "<tr><td>" & $destCol1 & "</td><td>" & $destCol2 & "</td><td>" & $col1 & "</td><td>" & $col2 & "</td></tr>";
}
Any suggestions how to proceed. thanks