我試圖根據列表中的錄製項目添加不同的詳細視圖。Sencha Touch 2 Ext.List - 以編程方式添加詳細視圖
- 我有使用List組件的主屏幕,並且此視圖顯示['Real estate','Vehicles','Jobs'] ...作爲菜單項。
- 根據列表中的選定項目,我想顯示不同的視圖。
- 我想跟進MVC設計模式..
下面是一些代碼... App.js
Ext.application({
name: 'App',
controllers: ['Main'],
views: ['Viewport', 'HomePage'],
stores: ['HomePageItems'],
models: ['HomePageItem'],
launch: function() {
Ext.Viewport.add(Ext.create('App.view.Viewport'));
}
});
Viewport.js
Ext.define("App.view.Viewport", {
extend: 'Ext.navigation.View',
requires: [ 'App.view.realestate.Realestate',
'App.view.HomePage',
'App.view.jobs.Jobs',
'App.view.other.Other',
'App.view.vehicles.Vehicles'
],
config: {
items: [
{
xtype: 'homepage'
}
]
}
});
HomePage.js(的xtype = 「主頁」)
Ext.define('App.view.HomePage', {
extend: 'Ext.List',
xtype: 'homepage',
id: 'homepage',
config: {
title: 'Oglasi',
itemTpl: '<strong>{name}</strong><p style="color:gray; font-size:8pt">{description}</p>',
store: 'HomePageItems',
onItemDisclosure: true
}
});
Main.js
Ext.define('App.controller.Main', {
extend: 'Ext.app.Controller',
config: {
refs: {
main: '#homepage'
},
control: {
'homepage': {
disclose: 'HookUpDetailView'
}
}
},
HookUpDetailView: function (element, record, target, index, ev) {
// TO DO: I have 4 differente views to load programmaticaly based on selected item in List
//'App.view.realestate.Realestate'
//'App.view.jobs.Jobs'
//'App.view.other.Other'
//'App.view.vehicles.Vehicles'
}
});
我找到了一個例子,但它不是爲我提前工作(push方法不存在)
this.getMain().push({
xtype: 'realestatehome'
});
謝謝!
是的......你說得對,它沒有任何意義(facepalm)。 幾分鐘後,我發佈了這個,我注意到我用「Ext.List」對象,而不是使用「Ext.navigation.View」 –