2013-02-28 71 views
0

我想使用.setActiveItem在Sencha 2.1 MVC应用程序中显示listview(Ext.dataview.List)中项目的详细信息。问题是我无法获得加载数据的详细视图。将数据加载到列表中的详细视图sencha touch 2 MVC

我已经尝试了很多不同的方法来获取详细视图来显示数据,包括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 
}, 

我的DetailView:

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>' 
    ], 
     }, 
}); 

回答

0

不知道这是不是最好的做法,但是这是我得到它的工作:

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

这看起来很好。我也这样做:我通常为自定义视图提供一个'record'配置,然后在'applyRecord'中执行'this.setData(record.getData())',但最后它是一样的。 – 2013-03-08 06:04:14