我有以下代码,我在其中尝试使用控制器将列表项的记录传递给详细视图。没有数据被传递,并且没有任何内容显示在详细视图中。
主.js:
Ext.define('EventsTest.view.Main', {
extend: 'Ext.navigation.View',
xtype: 'main',
requires: [
'EventsTest.store.Venues',
'Ext.dataview.List'
],
config: {
items: [
{
xtype: 'list',
id: 'venuesList',
itemTpl: '{name}, {distance}',
store: 'Venues',
onItemDisclosure: true,
styleHtmlContent: true
}
]
}
});
MainView.js:
Ext.define('EventsTest.view.MainView', {
extend: 'Ext.Container',
xtype: 'mainView',
config: {
title: JSON.stringify(this.data),
styleHtmlContent: true,
scrollable: true,
items: [
{
xtype: 'panel',
tpl: '<tpl for="."><h3>{name}</h3><br /><p>{distance}</p></tpl>',
flex: 1
}
]
}
});
Main.js(控制器:我已经尝试过 record.data(如在代码中的许多示例中所见)和 record.getData()
Ext.define('EventsTest.controller.Main', {
extend: 'Ext.app.Controller',
config: {
refs: {
venuesList: '#venuesList',
},
control: {
venuesList: {
disclose: 'showItemDetail'
}
}
},
showItemDetail: function(item, record) {
item.up('navigationview').push( {
xtype: 'mainView',
data: record.getData()
});
}
});
Venue.js(模型):
Ext.define('EventsTest.model.Venue', {
extend: 'Ext.data.Model',
config: {
fields: ['name', 'distance']
}
});
Venues.js(商店):
Ext.define('EventsTest.store.Venues', {
extend: 'Ext.data.Store',
reqiures: [
'EventsTest.model.Venue'
],
config: {
model: 'EventsTest.model.Venue',
data: [
{ name: 'Johnny', distance: '5 km' },
{ name: 'Billy', distance: '6 km' },
{ name: 'Sarah', distance: '7 km' },
{ name: 'William', distance: '8 km' },
]
}
});