Reputation: 377
In the Ext.window.Window component, I use the combobox field:
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;
}
}
);
};
When an attempt is made in the listeners of the render event to get an index entry, an error occurs:
TypeError: combo.getSelection (...) is nul
Why can an error occur and how to get index entries correctly? When adding a boxready event to get records, this event does not work.
Upvotes: 0
Views: 246
Reputation: 570
As you are using your definition of "initComponent" make sure you call
"this.callParent()"
at the end of definition of "initComponent".
At the time when "render" event is fired there wont be any selection hence you'll get empty array.
Explicitly set selection by something like "combo.setSelection(0)".
Upvotes: 1