我是 Sencha Touch 的新手。我在视图中有一个列表。我想在视图的初始功能中引用列表。在函数中,我将把 store 设置为列表。
我的观点:
Ext.define('NCAPP.view.tablet.MainMenu',{
extend:'Ext.Container',
xtype:'mainMenu',
id:'mainMenu',
requires:['Ext.TitleBar','Ext.dataview.List'],
config:{
loggedInUser:'',
fullscreen:true,
tabBarPosition: 'top',
items:[{
xtype:'titlebar',
title:'NetCenter APP',
items:[{
xtype:'list',
id:'menuList',
itemCls:'listItem'
}
]
}]
},
initialize: function () {
Ext.Viewport.setMasked({
xtype: 'loadmask',
message: 'Loading ...'
});
var moduleStore=Ext.create('NCAPP.store.Module');
moduleStore.load({
callback:function(records,operation,success){
Ext.Viewport.setMasked(false);
// I would like to refer to the list here and set store to it
var menu=this.menulist;
menu.setStore(moduleStore);
console.log(records);
},
scope:this
});
}
});
任何人都可以帮助我吗?谢谢
我的模型:
Ext.define('NCAPP.model.Module', {
extend:'Ext.data.Model',
config:{
fields:[
{ name:'id', type: 'int'},
{ name: 'name', type: 'string'},
{ name: 'description', type:'string'}
]
}
});
还有我的商店:
Ext.define('NCAPP.store.Module',{
extend:'Ext.data.Store',
config: {
model:'NCAPP.model.Module',
autoLoad:false,
proxy: {
type:'rest',
url:NCAPP.app.baseApiUrl+'/user/module/1/',
noCache: false,
//limitParam: false,
//enablePagingParams: false,
// startParam: false,
reader: {
type:'json',
rootProperty:'modules'
}
}
}
});