Reputation: 57
I am new to Sencha Touch. I have a list inside a view. I would like to refer to the list with in initial function of the view. And with in the function, I am going to set store to the list.
My View:
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
});
}
});
Can anyone help me please? Thanks
My Model:
Ext.define('NCAPP.model.Module', {
extend:'Ext.data.Model',
config:{
fields:[
{ name:'id', type: 'int'},
{ name: 'name', type: 'string'},
{ name: 'description', type:'string'}
]
}
});
And my store:
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'
}
}
}
});
Upvotes: 1
Views: 1404
Reputation: 14827
Since you've already set id
for your list, then you just need to use Ext.getCmp() to retrieve your list:
var menu = Ext.getCmp("menuList");
menu.setStore(moduleStore);
To populate the list afterwards, try refresh:
menu.refresh();
Upvotes: 2