我正在使用带有MVC的EXT.JS 4。
我有一个视图和一个控制器声明如下:
查看/公司/ MarketData.js
Ext.define('Market.view.company.MarketData', {
extend: 'Ext.form.Panel',
requires: ['Market.store.HistoricalMarketData'],
store:'HistoricalMarketData',
xtype: 'companyMarketData',
initComponent: function() {
this.callParent();
},
items: [{
xtype:'fieldset',
columnWidth: 0.5,
border:true,
padding:5,
//disabled:true,
collapsible: false,
defaultType: 'textfield',
defaults: {anchor: '100%'},
layout: 'anchor',
items :[{
fieldLabel: 'Time',
//xtype: 'displayfield',
name: 'time',
readOnly:true
}, {
fieldLabel: 'Open',
//xtype: 'displayfield',
name: 'open'
}, {
fieldLabel: 'High',
//xtype: 'displayfield',
name: 'high'
}, {
fieldLabel: 'Low',
//xtype: 'displayfield',
name: 'low'
}, {
fieldLabel: 'Close',
//xtype: 'displayfield',
name: 'close'
}, {
fieldLabel: 'Volume',
//xtype: 'displayfield',
name: 'volume'
}]
}]
});
查看/控制器/ ChartController.js
Ext.define('Market.controller.ChartController', {
extend:'Ext.app.Controller',
stores:['HistoricalMarketData'],
models: ['MarketData'],
views: ['company.MarketData'],
init: function() {
this.control({
'#companyChartItemId series[type=column]': {
itemmouseup:this.onItemMouseUp
},
'#companyChartItemId': {
mouseenter:this.onMouseEnter
}
});
},
onItemMouseUp: function (item) {
//do something
},
onMouseEnter: function (e) {
var view = this.getCompanyMarketDataView();
var form = view.superclass.getForm();
var store = this.getHistoricalMarketDataStore();
var data = store.getAt(0);
form.loadRecord(data);
}
});
问题是onmouseenter事件表单未定义:
onMouseEnter: function (e) {
var view = this.getCompanyMarketDataView();
var form = view.superclass.getForm();
有什么想法如何从视图中恢复表单?
答案 0 :(得分:1)
您可以使用Ext.ComponentQuery.query(),它返回一组匹配的组件。
例如
Ext.ComponentQuery.query('companyMarketData')[0].doSomething();
最好将itemIds用于组件。
另外,您是否尝试将默认参数传递给onMouseEnter函数?
您似乎在调用view.superclass.getForm(),但是您没有传递视图参数,该参数应该首先按顺序排列。相反,你正在通过e。