[英]I have a component define by itemid how I can get it in controller
我是煎茶新人。 我總是使用id定義我的組件。 但是現在我想將其更改為itemid。 我發現Ext.getcmp('id')不起作用。 當我使用Ext.componentquery.query('itemid')時,chrome中的控制台表示Ext.componentquery不是函數。 我能做什么?
我的查看代碼:
Ext.define('ylp2p.view.Main', {
extend: 'Ext.tab.Panel',
xtype: 'main',
requires: [
'Ext.TitleBar',
'Ext.carousel.Carousel',
'ylp2p.store.datainterests',
'Ext.Label',
'Ext.List'
],
config: {
fullscreen: true,
tabBarPosition: 'bottom',
scrollable: 'vertical',
items: [
{
title: '首頁',
iconCls: 'home',
styleHtmlContent: true,
//true to automatically style the HTML inside the content target of this component (body for panels).
scrollable: true,
layout: 'card',
items: [
{
docked: 'top',
xtype: 'titlebar',
title: 'ylp2p'
},
{
xtype: 'container',
layout: 'vbox',
items:[
{
xtype: 'label',
itemId: 'datalabel',---------this component is what i want
height: 50,
store: 'datainterests',
tpl: '金額:{data},利息:{earn}',
}//end label
]
}
]//end items
}
]
},//end config
//end listeners
});
我的控制器代碼:
Ext.define('ylp2p.controller.viewdata',{
extend: 'Ext.app.Controller',
launch: function(){
console.log('hello ! here is controller launch function');
var storeId = Ext.create('ylp2p.store.datainterests');
storeId.load({
callback: function(records, operation, success){
Ext.each(records, function(record) {
Ext.ComponentQuery.query("main > datalabel").setData({----it cant work . why?
data : record.get('data'),
earn : record.get('earn')
});
});
}
});
}
});
控制台錯誤說:
Uncaught TypeError: Ext.ComponentQuery.query(...).setData is not a function
我知道了
var label = Ext.ComponentQuery.query('main #datalabel')[0];
label.setData({
data : record.get('data'),
earn : record.get('earn')
});
我發現Sencha自己的代碼可以使用menu.down('#groupMenuItem')
訪問itemId:'groupMenuItem'
。 因此,您應該可以使用:
Ext.ComponentQuery.query('#itemid')
用這個。
var label = Ext.ComponentQuery.query('main #datalabel'); -- check on console label should not undefined
label.tpl.updateData -- you will find methods with tpl
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.