View Full Version : Properties vs Configs, in the Ext 4 Documentation

7 Jan 2012, 4:35 PM
In the main ExtJS Documentation, each class lists its configs and properties. What is the difference?


8 Jan 2012, 12:30 AM
My answer to this question is a little simplistic and idealistic. I'm afraid trying to give a full answer that covers all the subtleties is more likely to add to the confusion rather than clarifying the situation.

Config options are used to configure an object when it is created. Trying to set them as properties on the object after it has been instantiated will often have no effect.

Ext.create('Ext.panel.Panel', {
// config options go here

An object will have lots of properties but only the ones listed in the Properties section should be considered public properties. While there's nothing to stop you accessing the private properties you should only do it as a last resort, try to use the documented methods to manipulate them instead where possible.

// rendered is a public property used to indicate whether the panel has been rendered
if (panel.rendered) {
// could just do panel.el but that isn't a public property, so use getEl instead
var el = panel.getEl();

One reason why the lines get blurred is that objects generally copy their configs onto themselves like this:

Ext.apply(this, config);

This results in all the config options becoming private properties, at least initially. Internally classes can then manipulate those properties as appropriate but externally accessing those properties is a breach of encapsulation and should be avoided.

2 Oct 2012, 3:45 AM
A comment by renku about disabled been both a config and a property in 'Ext.button.Button' Sencha Documentation:

Pretty much all the config options are also properties. The Ext.Component constructor contains something along the lines of:

constructor: function(config) {
Ext.apply(this, config);

So all the passed in configs will become properties. Though, some get explicitly erased, a case with some deprecated configs that get renamed; yet others will be converted, like the view config gets converted to instance of View class.