我有一个要动态填充的列表,我想创建一个新视图,然后通过在项目上的按钮点击动态显示它(在选项卡视图中),但我认为我做的不正确,我怎样才能正确地实现这一点?
Ext.Loader.setConfig({
enabled: true
});
Ext.application({
name: 'MyApp',
launch: function () {
Ext.Viewport.add({
xclass: 'MyApp.view.Main'
});
}
});
Ext.define('MyApp.view.Main', {
extend: 'Ext.TabPanel',
config: {
fullscreen: true,
tabBarPosition: 'bottom',
defaults: {
styleHtmlContent: true
},
items: [
{xtype:'schedulecard'},
{xtype: 'settingscard'}
]
}
});
var scheduleItems = Ext.create('Ext.data.Store', {
storeId: 'schedulestore',
fields: ['name', 'day'],
sorters: 'day',
grouper: {
groupFn: function (record) {
return record.get('day')[0];
}
},
data: [
{ name: 'Cowper', day: 'Monday' },
{ name: 'Everett', day: 'Monday' },
{ name: 'University', day: 'Tuesday' },
{ name: 'Forest', day: 'Tuesday' }
]
}); // create()
Ext.define('MyApp.view.Schedule', {
extend: 'Ext.List',
xtype: 'schedulecard',
grouped: true,
config: {
title: 'Schedule',
iconCls: 'settings',
store: 'schedulestore',
itemTpl: '<span style="font-weight:bold;">{name}</span> {day}',
listeners: {
itemtap: function (list, index, item, evt) {
**//In here is where I wish to to display new View**
}
},
items: [{
xtype: 'titlebar',
docked: 'top',
title: 'MyApp'
}]
}
});
scheduleItems.add({ name: 'test', day: 'Wednesday' });
scheduleItems.add({ name: 'test', day: 'Wednesday' });
scheduleItems.add({ name: 'test', day: 'Wednesday' });
scheduleItems.add({ name: 'test', day: 'Wednesday' });
scheduleItems.add({ name: 'test', day: 'Thursday' });
scheduleItems.add({ name: 'test', day: 'Thursday' });
scheduleItems.add({ name: 'test', day: 'Thursday' });
scheduleItems.add({ name: 'test', day: 'Friday' });
scheduleItems.add({ name: 'test', day: 'Friday' });
Ext.define('MyApp.view.Settings', {
extend: 'Ext.Panel',
xtype: 'settingscard',
config: {
title: 'Settings',
iconCls: 'settings',
html: 'Settings new',
items: [{
xtype: 'titlebar',
docked: 'top',
title: 'MyApp',
items: [
{
align: 'left',
text: 'Back'
},
{
align: 'right',
text: 'refresh'
}
]
}]
}
});