dijit tree and focus node
I cannot get focusNode() or expandNode() get working. I also tried switching back to dojo 1.32 and even 1.3, no difference to 1.4. And I debugged wi开发者_运维技巧th firebug, the node is a valid tree node and no errors occur but the node wont get focused. Help is VERY appreciated!
<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>
focusNode() takes a dijit.TreeNode as a parameter, not a text string.
Probably you want to use Tree.attr("selectedItem", "DE").
You have to use set method in the following way:
tree.set('path', ['2', '1', '7']);
assuming that 2, 1, 7 are the path to the given node. And I have to mention that these are the Identities of the data store items.
visit here for more info: http://dojotoolkit.org/reference-guide/1.7/dijit/Tree-examples.html
Yes, I found the same, you need to use node[0]
var itemNode = tree._itemNodesMap["some_id"];
tree.focusNode(itemNode[0]);
the problem is the previous selected node continues focused two.
Any ideas on that.
精彩评论