以编程方式使用lastFocused方法仅高亮显示dojo树的最后一个节点

以编程方式使用lastFocused方法仅高亮显示dojo树的最后一个节点,dojo,dojox.grid.datagrid,dijit.tree,Dojo,Dojox.grid.datagrid,Dijit.tree,我怎样才能突出显示dojo树的最后一个节点例如:我想以编程方式突出显示层次结构中的“埃及”地球-->非洲-->埃及,那么我该如何实现这一点呢。我在一些dojo文档中读到,dojo的\u onNodeFocus方法中有一个lastFocus属性,它可以帮助我们解决这个问题。 有人可以建议如何使用这个函数作为我下面的例子。我找不到关于这个函数的很多文档或信息 <div data-dojo-type="dojo/store/Memory" data-dojo-id="myStore">

我怎样才能突出显示dojo树的最后一个节点例如:我想以编程方式突出显示层次结构中的“埃及”地球-->非洲-->埃及,那么我该如何实现这一点呢。我在一些dojo文档中读到,dojo的
\u onNodeFocus方法
中有一个
lastFocus属性
,它可以帮助我们解决这个问题。 有人可以建议如何使用这个函数作为我下面的例子。我找不到关于这个函数的很多文档或信息

<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>

这是setData([
{id:'世界',名称:'地球',类型:'行星',人口:'60亿'},
{id:'AF',名称:'Africa',类型:'Continental',人口:'900000000',面积:'30221532平方公里',
时区:'-1 UTC至+4 UTC',父级:'world'},
{id:'EG',name:'埃及',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:'constance',parent:'world'},
{id:'CN',name:'China',type:'country',parent:'AS'},
{id:'IN',name:'India',type:'country',parent:'AS'},
{id:'RU',name:'rusia',type:'country',parent:'AS'},
{id:'MN',name:'蒙古',type:'country',parent:'AS'},
{id:'OC',姓名:'Oceania',类型:'Continental',人口:'2100万',父母:'world'},
{id:'EU',名称:'Europe',类型:'Continental',父级:'world'},
{id:'DE',name:'dermany',type:'country',parent:'EU'},
{id:'FR',name:'France',type:'country',parent:'EU'},
{id:'ES',name:'西班牙',type:'country',parent:'EU'},
{id:'IT',name:'意大利',type:'country',parent:'EU'},
{id:'NA',名称:'North America',类型:'Continental',父级:'world'},
{id:'SA',名称:'South America',类型:'Continental',父级:'world'}
]);
//提供一个getChildren()方法来存储数据模型,其中
//子对象指向其父对象(也称为关系模型)
返回this.query({parent:this.getIdentity(object)});
全部崩溃
全部展开
选择南美洲内罗毕

我加载了您的示例代码(考虑将来自己创建一个JSFIDLE并提供链接来完成这项工作)。看来你已经有答案了。您的最后一个按钮似乎允许我们以编程方式选择项目。这不是你想要的吗?路径已经以硬编码的形式配置好了。我希望它能够始终导航到最后一个节点,而不是通过硬编码,而是动态导航