TreeStore:autoLoad 配置和 load() 函数之间的不同行为
TreeStore: different behaviour beetween autoLoad configuration and load() function
fiddle 中的测试用例与 autoLoad: true
一起工作,但与 autoLoad: false
一起工作(第 86 行),TreePanel 渲染前事件中第 161 行调用的 load() 函数未加载数据...
对于(非树)面板,我总是将 autoLoad
设置为 false 并在 GridPanel 的渲染器上加载商店,它工作得很好。我这样做是为了防止在开始时加载所有商店(有时设置过滤器)。
商店的 beforeload
事件正在防止双重加载。
这个 TreeStore 哪里是我的错?找了很久没有结果的解决方案...
我想我已经解决了你的问题。
为您的 TreeStore 使用根 属性。
/*
* Store
*/
Ext.define('Chronos.store.Clockings', {
extend : 'Ext.data.TreeStore',
requires: [
//'Chronos.store.Session'
],
model : 'Chronos.model.Presence',
autoLoad : false, //true, // false,
//autoSync : true, // DEBUG
sortOnLoad : false,
pageSize : 0,
remoteFilter: true,
root: {
id: 'id',
expanded: true
},
listeners: {
load: function(treestore, records, success) {
console.log(Date(), 'clockings loaded: ', success, treestore);
},
beforeload: function (treestore) {
if(treestore.isLoading()) return false;
}
}
});
希望这就是您要找的!
在此处解释的 Ext JS 4 中也存在类似问题ExtJS 4. Hidden treepanel with autoload false。
我在你的 fiddle 中所做的是我刚刚添加了以下内容
autoLoad: false,
root:{
//expanded: true, // optional
children: []
}
到您商店配置中的第 91
行。一切都神奇地工作。
fiddle 中的测试用例与 autoLoad: true
一起工作,但与 autoLoad: false
一起工作(第 86 行),TreePanel 渲染前事件中第 161 行调用的 load() 函数未加载数据...
对于(非树)面板,我总是将 autoLoad
设置为 false 并在 GridPanel 的渲染器上加载商店,它工作得很好。我这样做是为了防止在开始时加载所有商店(有时设置过滤器)。
商店的 beforeload
事件正在防止双重加载。
这个 TreeStore 哪里是我的错?找了很久没有结果的解决方案...
我想我已经解决了你的问题。
为您的 TreeStore 使用根 属性。
/*
* Store
*/
Ext.define('Chronos.store.Clockings', {
extend : 'Ext.data.TreeStore',
requires: [
//'Chronos.store.Session'
],
model : 'Chronos.model.Presence',
autoLoad : false, //true, // false,
//autoSync : true, // DEBUG
sortOnLoad : false,
pageSize : 0,
remoteFilter: true,
root: {
id: 'id',
expanded: true
},
listeners: {
load: function(treestore, records, success) {
console.log(Date(), 'clockings loaded: ', success, treestore);
},
beforeload: function (treestore) {
if(treestore.isLoading()) return false;
}
}
});
希望这就是您要找的!
在此处解释的 Ext JS 4 中也存在类似问题ExtJS 4. Hidden treepanel with autoload false。
我在你的 fiddle 中所做的是我刚刚添加了以下内容
autoLoad: false,
root:{
//expanded: true, // optional
children: []
}
到您商店配置中的第 91
行。一切都神奇地工作。