我是 sencha touch 应用程序开发的新手。我正在尝试将一些数据从远程服务器加载到列表中。我创建了一个商店,如下所示
Ext.regStore('customers',{
model : 'customer',
sorters : 'firstName',
storeId : 'customers',
data : [{
id : 100,
firstName : 'aaa'
}, {
id : 101,
firstName : 'sss'
}, {
id : 102,
firstName : 'rrrr'
}]
});
现在我需要修改这个商店以从外部服务器检索数据。Follwoing 是我现在正在使用的代码
var customers = new Ext.data.JsonStore({
model : 'customer',
proxy : {
type : 'ajax',
url:'http:sample.com',
reader : {
type : 'json',
root : '',
},
},
listeners : {
datachanged : function() {
customers.each(function(r) {
console.log('data in record is:'+ r.get('name'));
});
}
},
});
现在我的疑问是,如何像初始代码一样注册这个 JSON 存储以从另一个视图控制器文件访问存储。
提前致谢