0

How can I only highlight the last node of a dojo tree prpgramatically . For example : I want to highlight 'Egypt' of the hierarchy The Earth -->Africa-->Egypt programatically then how can I achieve that. I read in some dojo documents that there is a lastFocused property in the _onNodeFocus method of dojo which can help us fix this issue. Can someone suggest how to use this function for my below case as an example. I couldn't find much documentation or information about this function.

<div data-dojo-type="dojo/store/Memory" data-dojo-id="myStore">
    <!-- Create store with inlined data.
        For larger data sets should use dojo.store.JsonRest etc. instead of dojo.store.Memory. -->
    <script type="dojo/method">
         this.setData([
            { id: 'world', name:'The earth', type:'planet', population: '6 billion'},
            { id: 'AF', name:'Africa', type:'continent', population:'900 million', area: '30,221,532 sq km',
                    timezone: '-1 UTC to +4 UTC', parent: 'world'},
                { id: 'EG', name:'Egypt', type:'country', parent: 'AF' },
                { id: 'KE', name:'Kenya', type:'country', parent: 'AF' },
                    { id: 'Nairobi', name:'Nairobi', type:'city', parent: 'KE' },
                    { id: 'Mombasa', name:'Mombasa', type:'city', parent: 'KE' },
                { id: 'SD', name:'Sudan', type:'country', parent: 'AF' },
                    { id: 'Khartoum', name:'Khartoum', type:'city', parent: 'SD' },
            { id: 'AS', name:'Asia', type:'continent', parent: 'world' },
                { id: 'CN', name:'China', type:'country', parent: 'AS' },
                { id: 'IN', name:'India', type:'country', parent: 'AS' },
                { id: 'RU', name:'Russia', type:'country', parent: 'AS' },
                { id: 'MN', name:'Mongolia', type:'country', parent: 'AS' },
            { id: 'OC', name:'Oceania', type:'continent', population:'21 million', parent: 'world'},
            { id: 'EU', name:'Europe', type:'continent', parent: 'world' },
                { id: 'DE', name:'Germany', type:'country', parent: 'EU' },
                { id: 'FR', name:'France', type:'country', parent: 'EU' },
                { id: 'ES', name:'Spain', type:'country', parent: 'EU' },
                { id: 'IT', name:'Italy', type:'country', parent: 'EU' },
            { id: 'NA', name:'North America', type:'continent', parent: 'world' },
            { id: 'SA', name:'South America', type:'continent', parent: 'world' }
        ]);
    </script>
    <script type="dojo/method" data-dojo-event="getChildren" data-dojo-args="object">
         // Supply a getChildren() method to store for the data model where
         // children objects point to their parent (aka relational model)
         return this.query({parent: this.getIdentity(object)});
    </script>
</div>

<!-- Create the model bridging the store and the Tree -->
<div data-dojo-type="dijit/tree/ObjectStoreModel" data-dojo-id="myModel"
  data-dojo-props="store: myStore, query: {id: 'world'}"></div>

<!-- buttons to test Tree features -->
<button onclick="mytree.collapseAll();">
    Collapse all
</button>
<button onclick="mytree.expandAll();">
    Expand all
</button>
<button onclick="mytree.set('paths', [ ['world', 'AF', 'KE', 'Nairobi'], ['world', 'SA'] ] );">
    Select Nairobi, South America
</button>

<!-- Create the tree -->
<div data-dojo-type="dijit/Tree" data-dojo-id="mytree"
        data-dojo-props="model: myModel, autoExpand: true"></div>
Dojo_user
  • 281
  • 4
  • 9
  • 28
  • I loaded up your example code (consider doing this yourself in future by creating a jsFiddle and providing the link). It seems that you already have an answer. Your last button seems to allow us to select items programatically. Is this not what you were asking for? – Kolban Dec 06 '13 at 05:35
  • the path has been configured in hardcoded form I want it in a way to always navigate to the last node not by hardcoding but dynamically – Dojo_user Dec 06 '13 at 12:21

0 Answers0