我正在学习sencha,我不能在两个视图之间进行数据传输。我有2个看法。第一个视图有datalist。当点击datalist项目时我打开另一个视图。我需要将列表项值发送到第二个视图。
有人可以帮我吗?
第一个观点。
Ext.define('griddeneme.view.pnlAna', {
extend: 'Ext.Panel',
alias: 'widget.pnlana',
requires: [
'Ext.XTemplate'
],
config: {
layout: {
type: 'vbox'
},
items: [
{
xtype: 'panel',
flex: 1,
style: 'background-color:#81BEF7',
items: [
{
xtype: 'button',
docked: 'left',
height: 15,
itemId: 'mybutton1',
style: 'margin-Top',
ui: 'decline',
text: 'Çıkış'
}
]
},
{
xtype: 'panel',
flex: 9,
layout: {
type: 'vbox'
},
items: [
{
xtype: 'list',
flex: 1,
itemId: 'mylist',
itemTpl: [
'<div>{ad} - {yazar}</div>'
],
store: 'strYazarlar'
}
]
}
],
listeners: [
{
fn: 'onMybutton1Tap',
event: 'tap',
delegate: '#mybutton1'
},
{
fn: 'onMylistItemTap',
event: 'itemtap',
delegate: '#mylist'
}
]
},
onMybutton1Tap: function(button, e, eOpts) {
var pnlAna = Ext.create('griddeneme.view.pnlGiris');
Ext.Viewport.setActiveItem(pnlAna);
},
onMylistItemTap: function(dataview, index, target, record, e, eOpts) {
//alert(record.data.ad);
var Details=Ext.create('griddeneme.view.pnlDetail');
Details.setData(record);
Ext.Viewport.setActiveItem(Details);
}
});
第二种观点
Ext.define('griddeneme.view.pnlDetail', {
extend: 'Ext.Panel',
alias: 'widget.pnldetail',
config: {
layout: {
type: 'vbox'
},
items: [
{
xtype: 'panel',
flex: 1,
style: 'background-color:#81BEF7',
items: [
{
xtype: 'button',
docked: 'left',
height: 15,
ui: 'back',
text: 'Geri'
}
]
},
{
xtype: 'panel',
flex: 8,
itemId: 'mypanel7',
style: '',
items: [
{
xtype: 'label',
html: 'Kitap Adı:',
id: '',
minWidth: 150,
style: 'color:green; float:left'
},
{
xtype: 'label',
html: 'f',
id: 'lblAd'
},
{
xtype: 'label',
html: 'Yazar:',
minWidth: 150,
style: 'float:left;color:green;'
},
{
xtype: 'label',
html: 'ggg',
id: 'lblKitap'
}
],
listeners: [
{
fn: function(component, eOpts) {
alert(record.data.ad);
},
event: 'initialize'
}
]
}
]
}
});
答案 0 :(得分:0)
Ext.define('griddeneme.view.pnlDetail', {
extend: 'Ext.Panel',
alias: 'widget.pnldetail',
config: {
someData: null,
...
实例化你的pnlDetail:
onMylistItemTap: function(dataview, index, target, record, e, eOpts) {
var Details=Ext.create('griddeneme.view.pnlDetail',{
someData: // here you can set your data
});
Ext.Viewport.setActiveItem(Details);
}