我的帖子贏得了風滾草...真棒! :) 我想出了一個解決方法,在這裏。
var that = this;
this.trgTree =
new dijit.Tree({
model: this.trgTreeModel,
dndController: "dijit.tree.dndSource",
checkAcceptance: this.treeCheckAcceptance,
checkItemAcceptance: this.trgTreeCheckItemAcceptance,
getIconClass: app.getIcon,
onDndDrop: function(source, nodes, copy) {
that.handleDrop(that, dijit.getEnclosingWidget(
nodes[0]).item, this.current.item);
that.srcStore.save();
that.trgStore.save();
}
}, "trgTree");
handleDrop: function(inPage, inSrcItem, inTrgItem) {
console.info("*** start addItem: srcItem: " + inSrcItem.name[0]);
var srcType = inSrcItem.type[0];
var kids = inSrcItem.items;
if (inTrgItem.type != "fooType") {
// do something unique for fooType node targets
}
// add the item to the tree
inPage.addItem(inPage, inSrcItem, inTrgItem);
}
addItem: function(inPage, inSrcItem, inTrgItem) {
var srcType = inSrcItem.type[0];
var trgType = inTrgItem.type[0];
var theName = inSrcItem.name[0];
if (srcType == "fooType") {
srcType = inSrcItem.txType[0];
}
var newItem = {
id: inSrcItem.id[0],
name: theName,
type: srcType,
items: []
};
newItem = inPage.trgStore.newItem(newItem);
inPage.trgTreeModel.pasteItem(newItem, null, inTrgItem, false, 0);
var kids = inSrcItem.items;
if (kids !== undefined) {
// call recursively to add child items
for (var i in kids) {
inPage.addItem(inPage, kids[i], newItem);
// TODO: expand the node after it is added
}
}
},
所有這些代碼是具有是單個類的內部的情況下,其中這是類(這是一個爲本研究項目,所以類是wm.Page)。 對此缺乏細節和文檔感到抱歉,但這是很好的入門代碼。如果您對我的解決方法有具體疑問,只需詢問,我會盡力及時回答。
關於如何在WaveMaker論壇[這裏](http://dev.wavemaker.com/forums/?q=node/6219) –