dijit.Tree
은 ForestStoreModel
으로 데이터를 제공하기 위해 사용자 지정 데이터 저장소를 사용합니다. 잘 작동하지만 사용자가 dojo 끌어서 놓기 기능을 통해 최상위 항목 (및 최상위 항목 만)을 재정렬 할 수있는 기능을 제공하려고합니다.dijit 트리에서 최상위 노드 항목을 드래그 앤 드롭 방식으로 배열하는 방법
문제는 ForestStoreModel::pasteItem
함수가 루트의 하위 항목인지 확인한 다음 null
을 TreeStoreModel::pasteItem
에 전달하는 것입니다. 전달 된 부모 항목이 null 인 경우 TreeStoreModel
pasteItem: function(/*Item*/ childItem, /*Item*/ oldParentItem, /*Item*/ newParentItem, /*Boolean*/ bCopy, /*int?*/ insertIndex){
// summary:
// Move or copy an item from one parent item to another.
// Used in drag & drop
if(oldParentItem === this.root){
if(!bCopy){
// It's onLeaveRoot()'s responsibility to modify the item so it no longer matches
// this.query... thus triggering an onChildrenChange() event to notify the Tree
// that this element is no longer a child of the root node
this.onLeaveRoot(childItem);
}
}
dijit.tree.TreeStoreModel.prototype.pasteItem.call(this, childItem,
oldParentItem === this.root ? null : oldParentItem,
newParentItem === this.root ? null : newParentItem,
bCopy,
insertIndex
);
if(newParentItem === this.root){
// It's onAddToRoot()'s responsibility to modify the item so it matches
// this.query... thus triggering an onChildrenChange() event to notify the Tree
// that this element is now a child of the root node
this.onAddToRoot(childItem);
}
}
는 기본 데이터 저장소를 업데이트하지 않고 onLeaveRoot
및 onAddToRoot
이벤트는 insertIndex
에 통과하지 못한, 그래서 나는 것 같아 내 데이터 저장소 (업데이트하는 데 사용할 수 없습니다 어쨌든 조금 뒤쪽에있을 것입니다.) 이 시점에서
$root$
항목을 설정할 수 있도록하고
ForestStoreModel
가
TreeStoreModel
까지 변경되지 않은, 그것을 전달할 수 있도록하기 위해
ForestStoreModel
을 확장하는 것입니다 생각합니다.
다른 방법으로이 문제가 발생합니까?
업데이트
궁극적 인 해결책은 제안보다 더 간단 밝혀졌다. 내 ForestStoreModel
은 이미 dojo 1.6 ObjectStore를 데이터 소스로 사용하고 있으므로 사용자 정의 클래스이므로 options
인수의 원하는 인덱스를 객체 저장소 put
메소드에 전달할 수 있습니다.
pasteItem: function(/*Item*/ childItem, /*Item*/ oldParentItem, /*Item*/ newParentItem, /*Boolean*/ bCopy, /*int?*/ insertIndex){
// Handle drag & drop at the root level
if (oldParentItem === this.root && newParentItem === this.root){
this.store.put(childItem, { index: insertIndex });
}
this.inherited(arguments);
}
이 업데이트는 답변 일 것입니다. – DanMan