現在、django プロジェクトに取り組んでおり、dynatree を使用してツリービューを構築しています。最初のツリーにはユーザーが選択できるアイテムがあり、選択したアイテムは2番目のツリーに移動します。dynatree でこれを行う方法はありますか?また、ユーザーが項目を「選択解除」して、選択した項目が最初のツリーに戻るようにするオプションがあります。ユーザーがアイテムの選択を解除した場合、アイテムを元の親ノードに戻すにはどうすればよいですか? 前もって感謝します..
3 に答える
2
コンテキストメニューのコピー/貼り付けの概念を使用して問題を解決しました。2 番目の問題については、グローバル変数を使用して元の親ノードを格納したため、ユーザーがアイテムの選択を解除すると、元の親に戻ります。
于 2013-03-20T06:18:10.207 に答える
1
DIV dvAllLetterTemplates (マスター リストを含む) に dynamTree があり、項目がコピーされる DIV dvUserLetterTemplates があります。
//Select the Parent Node of the Destination Tree
var catNode = $("#dvUserLetterTemplates").dynatree("getTree").selectKey(catKey, false);
if (catNode != null) {
//Select the source node from the Source Tree
var tmplNode = $("#dvAllLetterTemplates").dynatree("getTree").selectKey(arrKeys[i], false);
if (tmplNode != null) {
//Make a copy of the source node
var ndCopy = tmplNode.toDict(false, null);
//Add it to the parent node
catNode.addChild(ndCopy);
//Remove the source node from the source tree (to prevent duplicate copies
tmplNode.remove();
//Refresh both trees
$("#dvUserLetterTemplates").dynatree("getTree").redraw();
$("#dvAllLetterTemplates").dynatree("getTree").redraw();
}
}
于 2013-10-03T15:18:21.413 に答える
0
「選択」と「アクティブ」には違いがあります。通常、選択はチェックボックスを使用して行われますが、アクティブ化できるノードは 1 つだけです (通常はマウス クリック)。アクティブ ノードを 2 回クリックしても「onActivate」イベントは発生しませんが、「onClick」ハンドラを実装してこれをキャッチし、node.deactivate() を呼び出すことができます。
于 2012-09-30T08:02:29.010 に答える