Extjs 4.1-如何将数据从一个存储加载到另一个存储
我有一个Extjs 4.1-如何将数据从一个存储加载到另一个存储,extjs,extjs4.1,Extjs,Extjs4.1,我有一个store1和自动加载:true store1 = Ext.create('Ext.data.Store', { fields: ['id', 'name'], autoLoad: true, proxy: { type: 'ajax', url: 'example.php', reader: { type: 'js
store1
和自动加载:true
store1 = Ext.create('Ext.data.Store', {
fields: ['id', 'name'],
autoLoad: true,
proxy: {
type: 'ajax',
url: 'example.php',
reader: {
type: 'json',
root: 'results' // see json output
}
}
});
我有一个网格存储2,带有自动加载:false
store2 = Ext.create('Ext.data.Store', {
fields: ['id', 'name'],
autoLoad: false,
proxy: {
type: 'ajax',
url: 'example.php',
reader: {
type: 'json',
root: 'results' // see json output
}
}
});
我不想再次加载存储2。我想从1号店买一样东西
grid.store2.loadData(store1.data) // fail
但是如何做到这一点,谢谢您可以从商店的
加载事件中获益,请尝试以下方法:
store1.addListener('load', function(records, operation, success) {
if(success) {
var obj = new Object();
obj.success = true;
obj.results = records;
grid.store2.loadData(obj);
}
});
您可以从商店的load
事件中获益,请尝试以下操作:
store1.addListener('load', function(records, operation, success) {
if(success) {
var obj = new Object();
obj.success = true;
obj.results = records;
grid.store2.loadData(obj);
}
});
您可以在代码之前添加。sortOnLoad=false
grid.store2.sortOnLoad=false
grid.store2.loadData(store1.data) // fail
您可以在代码之前添加。sortOnLoad=false
grid.store2.sortOnLoad=false
grid.store2.loadData(store1.data) // fail
但是如何在没有函数的情况下获取记录(记录,操作,成功){b/c我的网格稍后将初始化:(是的,我只是通过使用getRange()和一切工作感谢:)但是如何在没有函数的情况下获取记录(记录,操作,成功){b/c我的网格稍后将初始化:(是的,我只是通过使用getRange()和一切工作感谢:)