Why can't I extend the default options for a ComboBox in EXTJS?
I have several combo boxes. I want to DRY up the default options so I did this:
var defaultComboOptions = {
displayField开发者_如何学运维: 'name',
emptyText: 'Select a site...',
enableKeyEvents: true,
forceSelection: true,
listWidth: 300,
selectOnFocus: true,
triggerAction: 'all',
typeAhead: true,
typeAheadDelay: 125,
valueField: 'id',
width: 150,
xtype: 'combo'
};
var cbSites = new Ext.form.ComboBox(Ext.extend(defaultComboOptions, {
id:"myId",
x:200,
y:100,
listeners:{
}
}));
I only want to put what's different in each instance of a combobox.
I could do this in JQuery with a $.Extend(....
but I'm just not understanding ExtJS.
Thanks
Ext.extend()
is used to extend classes (deprecated in ExtJs 4). You should use Ext.apply()
which works like $.extend
in jQuery.
精彩评论