Tree dijit树和焦点节点

Tree dijit树和焦点节点,tree,focus,dojo,Tree,Focus,Dojo,我无法使focusNode()或expandNode()正常工作。我还尝试切换回Dojo1.32甚至1.3,与1.4没有区别。我用firebug进行了调试,该节点是一个有效的树节点,没有错误发生,但该节点不会聚焦。非常感谢您的帮助 <head> <script type="text/javascript"> dojo.declare("itcTree",[dijit.Tree], { focusNodeX : function(/* string

我无法使focusNode()或expandNode()正常工作。我还尝试切换回Dojo1.32甚至1.3,与1.4没有区别。我用firebug进行了调试,该节点是一个有效的树节点,没有错误发生,但该节点不会聚焦。非常感谢您的帮助

<head>
<script type="text/javascript">
    dojo.declare("itcTree",[dijit.Tree], {
         focusNodeX : function(/* string */ id)  {
                   var node=this._itemNodesMap[id];
                   this.focusNode(node);
         }
     });
    </script>
</head>

<body class="tundra">
    <div dojoType="dojo.data.ItemFileReadStore" jsId="continentStore" url="countries.json">
    </div>
    <div dojoType="dijit.tree.ForestStoreModel" jsId="continentModel" store="continentStore"
    query="{type:'continent'}" rootId="continentRoot" rootLabel="Continents"
    childrenAttrs="children">
    </div>
    <div dojoType="itcTree" id="mytree" model="continentModel" openOnClick="true">
        <script type="dojo/method" event="onClick" args="item">
            dijit.byId('mytree').focusNodeX('AF');
        </script>
    </div>
     <p>
    <button onclick="dijit.byId('mytree').focusNode('DE');">klick</button>
    </p>
</body>

declare(“itcTree”,[dijit.Tree]{
focusNodeX:函数(/*string*/id){
var node=this.\u itemNodesMap[id];
此.focusNode(节点);
}
});
dijit.byId('mytree').focusNodeX('AF');

克利克

focusNode()将dijit.TreeNode作为参数,而不是文本字符串


可能您想使用Tree.attr(“selectedItem”、“DE”)。

是的,我找到了相同的,您需要使用节点[0]

var itemNode = tree._itemNodesMap["some_id"];
tree.focusNode(itemNode[0]);
问题是前一个选定的节点继续聚焦两个节点


对此有什么想法。

您必须按以下方式使用set方法:

tree.set('path', ['2', '1', '7']);
假设2、1、7是到给定节点的路径。我必须提到,这些是数据存储项的标识

有关更多信息,请访问此处:

谢谢。我刚刚发现,如果我使用focusNode(节点[0]),上面的focusX函数可以工作。