tags:

views:

678

answers:

2

Hello,

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 with 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>
A: 

focusNode() takes a dijit.TreeNode as a parameter, not a text string.

Probably you want to use Tree.attr("selectedItem", "DE").

Bill Keese
Thanks. I just discovered that the above focusX function works if I use focusNode(node[0]).
A: 

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.

asantiago