代码之家  ›  专栏  ›  技术社区  ›  Jeaf Gilbert

带jquery的甘特图

  •  12
  • Jeaf Gilbert  · 技术社区  · 14 年前

    http://jsfiddle.net/JeaffreyGilbert/VkghS/

    当前,行之间的排序可以通过拖动barwrap(灰色)来完成。移动甘特条形图可以通过拖动条形图来完成。

    我想要的是排序和移动可以通过拖动条立即完成。如何做到这一点?

    2 回复  |  直到 8 年前
        1
  •  6
  •   Nathan MacInnes    14 年前

    $(function() {
        $( ".gantt" ).sortable({
            handle: '.bar' // Make it sortable by dragging the .bar instead of the container
        });
        /*
        $( ".bar" ).draggable({
            connectToSortable: '.gantt',
            containment: '.barWrap',
            grid: [20, 0]
        });
        */
        $( ".bar" ).resizable({
            handles: 'e, w',
            grid: [ 20, 0 ]
        });
    
        $(".gantt").disableSelection();
    });
    

    :你必须取出可拖动的,这在我看来还不错,因为人们仍然可以使用可调整大小来改变位置。您可以使用可拖动的句柄进行试验,以找到它们都工作的方法。

        2
  •  0
  •   Joe Coder    12 年前

    这是一个老问题,但您只需要添加另一个DIV包装器来实现这一点。( jsfiddle ):

    $(function() {
        $('.barWrap').wrapInner('<div class="sorter"></div>');
        $( ".gantt" ).sortable({
            handle: '.sorter'
        });
    
        $( ".bar" ).resizable({
            handles: 'e, w',
            grid: [ 20, 0 ]
        });
    
        $(".gantt").disableSelection();
    });