[英]Sencha touch 2 how to reference to a list item with in view?
我是Sencha Touch的新手。 我在視圖中有一個列表。 我想在視圖的初始功能中引用該列表。 在功能中,我將把存儲設置為列表。
我的觀點:
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'
}
}
}
});
由於您已經為列表設置了id
,因此只需使用Ext.getCmp()即可檢索列表:
var menu = Ext.getCmp("menuList");
menu.setStore(moduleStore);
要隨后填充列表,請嘗試刷新 :
menu.refresh();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.