View Full Version : subclass in two steps or one?

13 Nov 2009, 12:33 PM
in the iconcombo example (http://www.extjs.com/learn/Tutorial:Extending_Ext2_Class) you are creating the IconCombo object in one step, and then separately calling Ext.extend on it and then adding/overriding methods there.

what are the advantages/disadvantages of doing it that way versus doing it in one step like the following:

namespace.ComboBoxWithIcon = Ext.extend(Ext.form.ComboBox, {

initComponent: function(config) {

//constructor logic
setIconCls: function() {
var rec = this.store.query(this.valueField, this.getValue()).itemAt(0);
if(rec) {
this.flag.className = 'x-icon-combo-icon ' + rec.get(this.iconClsField);

// overriding the setValue method while preserving the superclass's code
setValue: function(value) {
Ext.ux.IconCombo.superclass.setValue.call(this, value);

13 Nov 2009, 1:03 PM
there is no real thing as a "one step" extension. they all amount to the same. The question really is do you extend form initComponent or constructor.