【发布时间】:2018-10-18 09:17:38
【问题描述】:
我在panel items 中有一个combobox,并在combobox listeners 中放置了一个select 事件。事件的函数调用一个全局方法,但这个全局函数在页面加载期间执行。
我在几个类上使用了这个组合框选择方法。因此,全局函数将很容易。因此需要在组合框的项目选择期间使用正常行为。我怎样才能实现这种调整?
全局功能:
Ext.define('MyApp.BaseMethods', {
requires: [],
singleton: true,
// Instead of using method content several times; passing comboname and required JSON value on arguments
comboQuery: function(comboname, JSONValue) {
var query = Ext.ComponentQuery.query(comboname)[0].getSelectedRecord();
var requiredValue = query.get(JSONValue);
return requiredValue;
},
});
和面板:
Ext.define('MyApp.view.FooPanel', {
extend: 'Ext.panel.Panel',
items: [{
xtype: 'foocombo',
listeners: {
// Trying to pass required information through parameters
select: MyApp.BaseMethods.comboQuery('[name=myfoocombo]', 'foojsonvalue'),
scope: me
}
}]
});
运行此方法时;全局函数在页面加载期间运行 button 点击显示 FooPanel 及其项目并给出错误,因为无法选择组合项目。;
Uncaught TypeError: Cannot read property 'getSelectedRecord' of undefined
【问题讨论】:
标签: javascript function extjs global listeners