gpt4 book ai didi

javascript - Extjs Treestore 子节点未加载

转载 作者:行者123 更新时间:2023-11-30 15:39:47 26 4
gpt4 key购买 nike

我可以看到子节点在第一个中加载,奇怪的是在第二个中没有加载?任何想法

在这里摆弄

https://fiddle.sencha.com/#view/editor&fiddle/1lss

Ext.application({
name: 'Fiddle',

launch: function () {
Ext.define('ComplexTree', {
extend: 'Ext.data.TreeStore',
alias: 'store.complextree',
storeId: 'ComplexTree',
root: {
expanded: true,
children: [{
text: 'test',
leaf: true
}, {
text: 'test2',
expanded: true,
children: [{
text: 'test21',
leaf: true
}, {
text: 'test22',
leaf: true
}]
}, {
text: 'test3',
leaf: true
}]
}
});

Ext.create('Ext.tree.Panel', {
title: 'Complex Tree',
width: 200,
height: 200,
store: Ext.create('ComplexTree'),
rootVisible: false,
renderTo: Ext.getBody()
});

Ext.create('Ext.tree.Panel', {
title: 'Complex Tree',
width: 200,
height: 200,
store: Ext.create('ComplexTree'),
rootVisible: false,
renderTo: Ext.getBody()
});
}
});

最佳答案

因为他们共享数据集(对象引用)。像这样修改您的商店:

Ext.define('ComplexTree', {
extend: 'Ext.data.TreeStore',
alias: 'store.complextree',

constructor: function (config) {
config = config || {};
config.root = {
expanded: true,
children: [{
text: 'test',
leaf: true
}, {
text: 'test2',
expanded: true,
children: [{
text: 'test21',
leaf: true
}, {
text: 'test22',
leaf: true
}]
}, {
text: 'test3',
leaf: true
}]
};
this.callParent([config]);
}
});

关于javascript - Extjs Treestore 子节点未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40990244/

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