2014-07-14 1 views
0

현재 유형 플러그 인을 사용하여 유형이있는 각 노드를 정의하는 2 개의 jstree가 있습니다. 내 문제는 하나의 노드를 jstree # 1에서 "Topic"유형으로 "Folder"유형의 노드와 다른 트리 jstree # 2로 드래그하면 단지 빨간색 X가 나타납니다. 으로 정의 된 "folder"유형이 있습니다. "valid_children": jstree # 2의Jstree Valid_Children between trees 여러 나무 사이의 유효한 자식

jstree # 1 Toolbox. 특정 노드를 다른 노드로 드래그하는 데 사용됩니다. "Always_copy"

.jstree({ 
    "core": { 
     //Prevent node from being deleted when moved to the design tree 
     "check_callback": function (operation, node, node_parent, node_position, more) { 

     }, 
     "data": { 
      "url": getToolTreeUrl, 
      "data": function (node) { 
       return { 'id': node.id }; 
      } 
     } 
    }, 
    //Enabled the drag and drop plugin with ability to drag and drop between tree 
    "plugins": ["dnd", "unique", "types", "ccrm"], 
    "crrm": { 
     "move": { 
      "check_copy": function() { 
       alert("Check_Copy"); 
      }, 
     }, 
    }, 
    "types": { 
     "#": { 
      "max_children": 1, 
      "max_depth": 2 
     }, 
     "Topic": { 
      "valid_children": "Task" 
     }, 
     "Task": { 
      "valid_children": "Task" 
     }, 
     "Paragraph": { 

     }, 
     "Dictionary_List": { 

     }, 
     "Ordered_List": { 

     }, 
     "Unordered_List": { 

     }, 
     "List_Item": { 

     }, 
     "Picture": { 

     }, 
     "Video": { 

     }, 
     "Table": { 

     }, 
     "Note": { 

     }, 
     "QHSE-Note": { 

     }, 
    }, 
    "dnd": { 
     always_copy: true, 
     is_draggable: function (data) { 
      return data[0].id != 0; //disallow entire toolbox being dragged 
     }, 
    }, 
    rules: { 
     multitree: true, 
     draggable: "all" 
    } 
}); 

}

jstree # 2 도구 상자에서 노드를 받아 내 문서입니다.

.jstree({ 
    "core": { 
     "check_callback": function (operation, node, node_parent, node_position, more) { 
      var type = node.text; 
      var parentValue = node.parent; 

      if (operation == "move_node") { 
       asyncPost(getObjectLogicCheckUrl); 
      } 
      if (operation == "copy_node") { 
       asyncPost(getObjectLogicCheckUrl); 
      } 
     }, 
     "data": data 
    }, 
    "plugins": ["dnd", "contextmenu", "types"], contextmenu: { items: customMenu }, 
    "crrm": { 
     "move": { 
      "check_copy": function() { 
       alert("Check_Copy"); 
      }, 
     }, 
    }, 
    "types": { 
     "#": { 
      "max_children": 1 
     }, 
     "Topic": { 
      //"valid_children": "Task" 
     }, 
     "Task": { 
      //"valid_children": ["Task", "Paragraph", "Dictionary_List", "Ordered_List", "Unordered_List", "Picture", "Video", "Table", "Note", "QHSE-Note"], 
     }, 
     "Paragraph": { 
      //"valid_children": ["Paragraph", "Dictionary_List", "Ordered_List", "Unordered_List", "Picture", "Video", "Table", "Note", "QHSE-Note"] 
     }, 
     "Dictionary_List": { 
      "valid_children": ["List_Item"] 
     }, 
     "Ordered_List": { 
      "valid_children": ["List_Item"] 
     }, 
     "Unordered_List": { 
      "valid_children": ["List_Item"] 
     }, 
     "List_Item": { 
      "max_children": 0 
     }, 
     "Picture": { 
      "max_children": 0 
     }, 
     "Video": { 
      "max_children": 0 
     }, 
     "Table": { 
      "max_children": 0 
     }, 
     "Note": { 

     }, 
     "QHSE-Note": { 

     }, 
     "Folder": { 
      "valid_children": "Topic" 
     }, 
    }, 
    rules: { 
     multitree: true, 
     draggable: "all", 
    }, 

문서 트리에서 노드를 드래그 할 수있는 방법을 고민 중입니다. IE .. "Topic"유형의 노드는 "Task"유형의 노드 만 채택 할 수 있습니다.

유형 플러그인이 여러 나무 사이에서 작동하도록하는 방법을 알고 있다면 도와주세요.

답변

0

나는 그것을 알아 냈다. 두 트리 노드 모두 동일한 규칙을 적용해야 작동 할 수 있습니다.

jstree # 1

"Topic": { 
     "valid_children": "Task" 
    }, 

jstree # 2

"Topic": { 
     "valid_children": "Task" 
    },