gpt4 book ai didi

javascript - TypeError : combo. getSelection (...) 在渲染事件中为 null。扩展6

转载 作者:行者123 更新时间:2023-12-03 00:55:00 25 4
gpt4 key购买 nike

在 Ext.window.Window 组件中,我使用组合框字段:

Ext.define('BookApp.view.BookEdit', {
extend: 'Ext.window.Window',
alias: 'widget.bookwindowedit',
layout: 'fit',
autoShow: true,
store: 'BookStore',
modal : true,
initComponent: function() {
var me = this;
me.myStates = Ext.data.StoreManager.get('States').load();
me.items = [{
xtype: 'form',
items: [
{
xtype: 'combobox',
fieldLabel: 'Статус',
name: 'status',
store: me.myStates,
valueField: 'name',
displayField: 'name',
typeAhead: true,
queryMode: 'remote',
listeners: {
'select': function (combo, records) {
index = records.internalId;

filterCombo(combo, index);
},

'boxready': function () {
console.log("form's boxready");
index = combo.getSelection().internalId;
filterCombo(combo, index);
}
}
},
]
}];
me.buttons = [{
text:'Save',
iconCls:'save-icon',
action: 'save'
},
{
text: 'Clear',
scope: this,
action: 'clear'
}
];

me.callParent(arguments);
}
});



function filterCombo(combobox, index) {
store = combobox.getStore();
store.clearFilter();
store.filterBy(
function(record) {
if ((record.data.order_install == index - 1) || (record.data.order_install == index + 1)) {
return true;
} else {
return false;
}
}
);
};

当尝试在渲染事件的监听器中获取索引条目时,会发生错误:

TypeError: combo.getSelection (...) is nul

为什么会出现错误以及如何正确获取索引条目?添加boxready事件获取记录时,该事件不起作用。

最佳答案

当您使用“initComponent”的定义时,请确保调用“this.callParent()”在“initComponent”定义的末尾。当“render”事件被触发时,不会有任何选择,因此您将得到空数组。通过“combo.setSelection(0)”之类的方式显式设置选择。

关于javascript - TypeError : combo. getSelection (...) 在渲染事件中为 null。扩展6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52876000/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com