Sencha touch 从sencha touch 2 MVC列表将数据加载到详细视图中
我试图在Sencha 2.1 MVC应用程序中使用.setActiveItem来显示listview(Ext.dataview.List)中项目的详细信息。问题是我无法获得加载数据的详细视图 我尝试了许多不同的方法来获取详细视图以显示数据,包括setData、setRecord和Update(我最近的一些尝试见下文) 我在搜索论坛、stackoverflow和google时得到的大多数结果都是针对不使用MVC模式的sencha应用程序的。 (哦,使用.push可以很好地工作,但由于其他原因,我将离开导航视图) 从我的控制器:Sencha touch 从sencha touch 2 MVC列表将数据加载到详细视图中,sencha-touch,sencha-touch-2,sencha-touch-2.1,Sencha Touch,Sencha Touch 2,Sencha Touch 2.1,我试图在Sencha 2.1 MVC应用程序中使用.setActiveItem来显示listview(Ext.dataview.List)中项目的详细信息。问题是我无法获得加载数据的详细视图 我尝试了许多不同的方法来获取详细视图以显示数据,包括setData、setRecord和Update(我最近的一些尝试见下文) 我在搜索论坛、stackoverflow和google时得到的大多数结果都是针对不使用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>'
],
},
});
Ext.define('Labblistan.view.LabDetail'{
扩展:“Ext.Panel”,
xtype:'labdetail',
id:“labdetail”,
配置:{
标题:“{Analysis}”,
styleHtmlContent:对,
可滚动:“垂直”,
全屏:对,
第三方物流:[
“关于{Analysis}{Comment}的信息”
],
},
});
我不知道这是否是最佳实践,但我就是这样做到的:
Ext.getCmp('mainpanel').setActiveItem({
xtype: 'labdetail',
title: 'Detaljinformation',
data: record.getData()
});
这看起来不错。我也这样做:我通常为我的自定义视图提供一个
记录
配置,然后在applyRecord
中,我做这个.setData(record.getData())
,但最后它是一样的。