0

我正在使用 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);
},

谢谢!!

4

1 回答 1

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);
},
于 2013-05-09T15:52:40.003 回答