我正在使用sencha touch o'really示例。会议是否与会议和发言人相关联。想象一下,我有一个会话列表,当点击视图更改会话详细信息时。
我有这样的观点:
Ext.define('MyApp.view.session.Detail', {
extend: 'Ext.Container',
xtype: 'session',
config: {
layout: 'vbox',
title: '',
items: [
{
flex: 1,
layout: 'fit',
scrollable: 'vertical',
xtype: 'sessionInfo'
},
{
flex: 2,
xtype: 'speakers',
store: 'SessionSpeakers',
items: [
{
xtype: 'listitemheader',
cls: 'dark',
html: 'Speakers'
}
]
},
{
flex: 1,
xtype: 'button',
text: "Decline Button" ,
handler: function () {
/*HERE I WANT TO PUT SOME DATA FROM THE SESSION OBJECT. FOR EXAMPLE */
alert({title});
alert({start_date});
alert({location});
}
}
]
}
}); 所以,我想将{title} {start_date} {location}替换为当前会话的相应值。
顺便说一下,在控制器中我有这个:
onSessionTap: function(list, idx, el, record) {
var speakerStore = Ext.getStore('SessionSpeakers'),
speakerIds = record.get('speakerIds');
speakerStore.clearFilter();
speakerStore.filterBy(function(speaker) {
return Ext.Array.contains(speakerIds, speaker.get('id'));
});
if (!this.session) {
this.session = Ext.widget('session');
}
this.session.setTitle(record.get('title'));
this.getSessionContainer().push(this.session);
this.getSessionInfo().setRecord(record);
},
谢谢!
答案 0 :(得分:0)
我可以解决它。 我不得不在运行时创建按钮。 :
在会话视图中:
Ext.define('MyApp.view.session.Detail', {
extend: 'Ext.Container',
xtype: 'session',
config: {
layout: 'vbox',
title: '',
items: [
{
flex: 1,
layout: 'fit',
scrollable: 'vertical',
xtype: 'sessionInfo'
},
{
flex: 2,
xtype: 'speakers',
store: 'SessionSpeakers',
items: [
{
xtype: 'listitemheader',
cls: 'dark',
html: 'Speakers'
}
]
}
]
}
});
在会话控制器中:
onSessionTap: function(list, idx, el, record) {
var speakerStore = Ext.getStore('SessionSpeakers'),
speakerIds = record.get('speakerIds');
speakerStore.clearFilter();
speakerStore.filterBy(function(speaker) {
return Ext.Array.contains(speakerIds, speaker.get('id'));
});
if (!this.session) {
this.session = Ext.widget('session');
}
else{
//To avoid multiple buttons
this.session.removeAt(2);
}
this.session.setTitle(record.get('title'));
this.session.add(
Ext.Button.create({
flex: 1,
xtype: 'button',
text:'My button' ,
handler: function () {
alert(record.get('title'));
alert(record.get('start_date'));
} })
);
this.getSessionContainer().push(this.session);
this.getSessionInfo().setRecord(record);
},