gpt4 book ai didi

javascript - Extjs TreePanel 未展开

转载 作者:行者123 更新时间:2023-11-30 06:31:48 26 4
gpt4 key购买 nike

我加载了一个项目展开的 TreePanel(在我的 json 中定义)但是当它显示时它没有展开。

只是打开了目录(图标),但没有显示项目。我加载它使用加载存储功能重新加载我的树面板。

enter image description here

storeTree = me.getTreePersonneStore();

storeTree.load({
params: {
idPersonne: batch.proxy.getReader().jsonData.id,
lettrePersonne: batch.proxy.getReader().jsonData.lettre
}
})

我的商店:

    Ext.define('ModuleGestion.store.TreePersonne', {
extend: 'Ext.data.TreeStore',

requires: [
'ModuleGestion.model.Personne'
],

constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
model: 'ModuleGestion.model.Personne',
storeId: 'StoreTreePersonne',
root: {
expanded : true,
text : 'Personnes',
expandable : true,
id : 'root',
nodeType:'async',
uiProvider:false
},
proxy: {
type: 'ajax',
node: 'id',
url: 'ModuleGestion/php/TreePersonne.php',
reader: {
type: 'json'
}
},
listeners: {
beforeload: {
fn: me.beforeload,
scope: me
}
}
}, cfg)]);
},

beforeload: function(store, operation, eOpts) {
operation.params.node = operation.node.get("id");
}

});

我的 JSON:

[{
id:"A",
text:"A",
expanded:true,
children:[
{
id:"101",text:"AA AA",leaf:true},
{id:"98",text:"AA AA",leaf:true},
{id:"86",text:"AA AA",leaf:true},
{id:"99",text:"AA AA",leaf:true},
{id:"96",text:"AA AA",leaf:true},
{id:"100",text:"AA AA",leaf:true},
{id:"97",text:"AA AA",leaf:true}]
}],
}]

我的树:

{
xtype: 'treepanel',
id: 'TreePersonne',
store: 'TreePersonne',
viewConfig: {
}
}

最佳答案

试试下面的 json。 child 也有扩展属性。

[{
id:"A",
text:"A",
expanded:true,
children:[
{
id:"101",text:"AA AA",leaf:true, expanded:true},
{id:"98",text:"AA AA",leaf:true, expanded:true},
{id:"86",text:"AA AA",leaf:true, expanded:true},
{id:"99",text:"AA AA",leaf:true, expanded:true},
{id:"96",text:"AA AA",leaf:true, expanded:true},
{id:"100",text:"AA AA",leaf:true, expanded:true},
{id:"97",text:"AA AA",leaf:true, expanded:true}]
}],
}]

或者,您也可以在面板加载后展开子项:

YOUR_TREE_PANEL.expandChildren(true);

关于javascript - Extjs TreePanel 未展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17077992/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com