I cannot believe how frustrating this is.
I have a combo box that I define and use in several places. I am using ExtJS 5.0.1
It has a simple in-memory store.
All I want to do is get it to automatically select the first record upon creation.
Here it is:
Ext.define('MYAPP.view.simplestatus.SimpleStatusCombo', {
extend: 'Ext.form.field.ComboBox',
xtype: 'simple-status-combo',
autoSelect: true,
editable: false,
fieldLabel: 'Status',
queryMode: 'local',
store: [ ['ACTIVE', 'Active'], ['COMPLETE', 'Complete'], ['CANCELLED', 'Cancelled'] ],
width: 160,
initComponent: function () {
this.labelWidth = 60;
this.setRawValue('ACTIVE'); // DOES NOT WORK
this.callParent(arguments);
}
});
That does not work. It will work if I put a slight delay in the initComponent which is grounds for termination as far as I'm concerned. Calling 'setValue" also does not work.
Ext.define('MYAPP.view.simplestatus.SimpleStatusCombo', {
extend: 'Ext.form.field.ComboBox',
xtype: 'simple-status-combo',
autoSelect: true,
editable: false,
fieldLabel: 'Status',
queryMode: 'local',
store: [ ['ACTIVE', 'Active'], ['COMPLETE', 'Complete'], ['CANCELLED', 'Cancelled'] ],
width: 160,
initComponent: function () {
var self = this;
this.labelWidth = 60;
// THIS WORKS but is UGLY and STUPID
setTimeout(function() {
self.setRawValue('ACTIVE');
}, 250);
this.callParent(arguments);
}
});
What am I missing here?
Thanks