2012-09-12 60 views
2

我有jsTreeDataTable。我試圖將我從樹中拖出的節點複製到表格中的單元格中。是不是有可能呢?使用jsTree和DataTables拖放

它甚至不顯示警報

這是我的html:

<li id="tree1" class="jstree-draggable"> 

</li> 

<table id="table"> 
    <thead> 
     <tr> 
      <th>1 Column</th> 
      <th>2 Column</th> 
     </tr> 
    </thead> 
    <tbody> 

    </tbody> 
</table> 

這是我的JS:

$(document).ready(function() { 

    $("#tree1").jstree({ 
     // List of active plugins 
     "plugins" : ["themes", "html_data", "dnd"], 
     "html_data" : { 
      "data" : "<li id='root'><a href='#'>Parent node</a><ul><li><a href='#'>Child node</a></li></ul></li>" 
     }, 
     "themes" : { 
      "theme" : "default", 
      "dots" : true, 
      "icons" : true 
     }, 
     "dnd" : { 
      "drop_finish" : function() { 
       alert("DROP"); 
      }, 
      "drag_check" : function() { 

      }, 
      "drag_finish" : function (data) { 
       alert("DRAG FINISH"); 
      } 
     }, 
     "core" : { 
      "initially_open" : ["root"] 
     } 
    }); 

    $('#table').dataTable({ 
     "bPaginate" : false, 
     "bSort" : false, 
     "bInfo" : false, 
     "bFilter" : false 
    }); 
}); 

我有第二樹(它本質上是相同的),並拖動它們之間的兩個作品(除非我嘗試在其自己的p上放置一個子元素在這種情況下,整棵樹消失,但這不是我的主要問題)

我試過this線程的答案,但它仍然沒有顯示警報。

上HOWTO任何幫助解決這個問題,非常感謝(它沒有使用jstree,這正是我偶然發現)

回答

0

當事情是樹本身內部下降的下降回調被調用。 。 爲了實現你正在嘗試的你必須標記你的表爲「droppable」,並允許拖放元素在裏面。 這是一個插件,是JQuery UI的一部分。 使用本文檔做到這一點..

Droppable Documentation