1
我是Sencha Touch的新手。我在視圖中有一個列表。我想在視圖的初始功能中參考該列表。在功能中,我打算將商店設置到列表中。Sencha touch 2如何引用可見列表項?
筆者認爲:
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'
}
}
}
});
感謝爲你的答案。現在我該如何填充商店列表? (我已經用模型和商店代碼編輯了這個問題) – Shree
你可以給你的商店一個'storeId',然後使用'var moduleStore = Ext.getStore(storeId)'獲得商店並且像上面那樣設置商店 – Eli