【问题标题】:Load data into detailed view from list sencha touch 2 MVC从列表 sencha touch 2 MVC 将数据加载到详细视图中
【发布时间】:2013-02-28 14:59:51
【问题描述】:

我正在尝试使用 .setActiveItem 在 Sencha 2.1 MVC 应用程序的列表视图 (Ext.dataview.List) 中显示项目的详细信息。问题是我无法获取加载数据的详细视图。

我尝试了许多不同的方法来获取详细视图以显示数据,包括 setData、setRecord 和 Update(请参阅下面的一些最新尝试)。

我在论坛、stackoverflow 和谷歌搜索时得到的大部分结果都是针对不使用 MVC 模型的 sencha 应用程序。 (哦,使用 .push 可以正常工作,但由于其他原因,我正在远离导航视图)。

来自我的控制器:

showDetail: function(list, record) {
    /*this.getMain().push({
        xtype: 'labdetail',
        title: record.fullName(),
        data: record.getData()
    });*/
//The code above works, but only as long as I stay with navigation view...
    console.log("showDetail");
       //Ext.getCmp('labdetail').update(record.data);
       //LabDetail.update(record.data);
       //Ext.fly('labdetail').setData(record.data);
       //Ext.getCmp('labdetail').setData(record.data);
       //Ext.component('Labblistan.view.LabDetail').destroy();
       //Ext.getCmp('Labblistan.view.LabDetail').destroy();
       //Ext.fly('labdetail').destroy();
       //var DetailView = Ext.create('Labblistan.view.LabDetail'); //If I create the view the console complains I need to destroy previous views with the same ID, hence the different destroy() approaches above
       //DetailView.setRecord(record);
       Ext.getCmp('mainpanel').setActiveItem('labdetail'); //This navigates to the right view, but it's empty
},

我的详细视图:

Ext.define('Labblistan.view.LabDetail', {
extend: 'Ext.Panel',
xtype: 'labdetail',
id: 'labdetail',
config: {
    title: '{Analysis}',
    styleHtmlContent: true,
    scrollable: 'vertical',
    fullscreen: true,
    tpl: [
        '<div style=position:absolute;top:50px;><p>Info about {Analysis}</p><p>{Comment}</p></div>'
    ],
       },
});

【问题讨论】:

    标签: sencha-touch sencha-touch-2 sencha-touch-2.1


    【解决方案1】:

    不知道这是否是最佳实践,但这就是我的工作方式:

    Ext.getCmp('mainpanel').setActiveItem({
           xtype: 'labdetail',
           title: 'Detaljinformation',
           data: record.getData()
    });
    

    【讨论】:

    • 这看起来不错。我也是这样做的:我通常为我的自定义视图提供一个record 配置,然后在applyRecord 我做this.setData(record.getData()),但最后它是一样的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-21
    相关资源
    最近更新 更多