可以在创建 TreePanel 时,设置 rootVisible 属性为 false。这样,只会展示从 TreeStore 返回的数据的第一项,而不会显示根节点。示例代码如下:

Ext.create('Ext.tree.Panel', {
    store: Ext.create('Ext.data.TreeStore', {
        root: {
            text: 'Root',
            expanded: true,
            children: [{ 
                text: 1, 
                id: 1, 
                expanded: true, 
                children: [{ 
                    id: 11, 
                    text: '11' 
                }, { 
                    id: 12, 
                    text: '12' 
                }] 
            }, { 
                text: 2, 
                id: 2 
            }]
        }
    }),
    rootVisible: false, // 设置 rootVisible 为 false
    renderTo: Ext.getBody()
});
在extjs中ExtdataTreeStore 请求返回的数据是 text 1 id 1 expanded true children id 11 text 11 id 12 text 12 text 2 id 2 我只想展示数据第一项怎么办

原文地址: https://www.cveoy.top/t/topic/0nq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录