如何才能以prpgramatically方式突出显示dojo树的最后一个节点。 例如:我想以编程方式突出显示层次地球 - >非洲 - >埃及的'埃及',然后我该如何实现这一点。我在一些dojo文档中读到,dojo的lastFocused property
中有一个_onNodeFocus method
可以帮助我们解决这个问题。
有人建议如何使用此功能作为我的下面的案例作为一个例子。我找不到很多关于这个功能的文档或信息。
<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>