拖放2个表之间使用Jquery排序与rowspan和colspan

Drag and Drop between 2 tables using Jquery sortable with rowspan and colspan

本文关键字:排序 rowspan colspan Jquery 2个 之间 拖放      更新时间:2023-09-26

我正在尝试将rowspan> 2或colspan> 2的行移动到另一个表中。

问题是,当我将它放入单元格中时,它会在该单元格中创建一个新的tr。

我想设置父rowspan或colspan相同的子当拖动对象被丢弃。

http://jsbin.com/jumalofe/1/watch?html、js、输出

假设"AIBD"应该从08-00到12:00。我该怎么做呢?

你应该这样做。我们将使用sortable:

receive事件

当连接的可排序列表中的项被删除时触发此事件被放到了另一个列表中。后者是事件目标。

receive:function(event, ui) {
      //we check if the <td> has rowspan property
     if(typeof ui.item.attr('rowspan') !== 'undefined' && ui.item.attr('rowspan') !== false){
        //if it does, we store it in a variable
        rowspan = ui.item.attr('rowspan');
        //the element we are dropping to, we set the rowspan there
        //(content is automatically inserted)
        $(this).attr('rowspan',rowspan);
        //we set the rowspan of sender element to 0, this is the case where
        //you are re-dragging the 'AIDB' to some other row, if you do, 
        //we want the previous row to be same as before, free of any rowspan
        ui.sender.attr('rowspan',0);
      }
      //same case for colspan
      if(typeof ui.item.attr('colspan') !== 'undefined' && ui.item.attr('colspan') !== false){
        colspan = ui.item.attr('colspan');
        $(this).attr('colspan',colspan);
        ui.sender.attr('colspan',0);
      }
}