extjs6。使用第二存储构造函数中第一存储的数据
有2家商店。我需要来自第二个存储构造函数中第一个存储的数据。怎么做呢?这很容易,但没用 要实现您想要的,您必须从store1的load()事件创建store2,并且在所述load事件之前,您不能将store绑定到任何组件extjs6。使用第二存储构造函数中第一存储的数据,extjs,store,Extjs,Store,有2家商店。我需要来自第二个存储构造函数中第一个存储的数据。怎么做呢?这很容易,但没用 要实现您想要的,您必须从store1的load()事件创建store2,并且在所述load事件之前,您不能将store绑定到任何组件 Ext.define('MyApp.store.Store1',{ ... listeners:{ load:function(store, records) { var store2 = Ext.getStore("st
Ext.define('MyApp.store.Store1',{
...
listeners:{
load:function(store, records) {
var store2 = Ext.getStore("store2") || Ext.create('MyApp.store.Store2',{
store1data: records
});
Ext.getCmp("someCombobox").bindStore(store2); // you would have to use ext-empty-store on the combobox before, or else it may trigger store creation too early
}
但这不是一种好的编程风格,也没有任何实际用途。通常,每当store1获得新数据时,您都希望再次调用store2的某个函数。在商店构建过程中,您几乎不需要做任何事情,这些事情在以后使用reconfigure
或其他商店方法无法完成。(值得注意的例外:您必须在构建过程中决定它是数组存储、json存储还是树存储)
例如,您可以在store2上定义一个方法,并在store1重新加载后调用该方法:
store2.someFunction = function(store1Records) {
var store2 = this;
Ext.each(store1Records,function(record) {
store2.getProxy().setExtraParam(record.get("paramName"),record.get("paramValue"));
});
store2.load();
}
store1.on('load',function(store, records) {
store2.someFunction(records);
});
为什么不能直接使用
store2.loadData()
?一个简单的store2.loadData(store1.getRange())
应该可以用。我已经试过了,但是没有用。不知何故,数据只在所有构造函数之后加载。即使我让第一商店同步。你真的应该发布一些代码来了解你的工作流程。目前,我认为你的工作流程不起作用。您不应该需要在存储构造函数中提供任何数据。编辑:或者,你不是指构造函数,而是指配置对象。请看这里: