PDA

View Full Version : Right place for config definition in extended classes?



fenderico
6 Dec 2012, 11:14 AM
Hi everybody,

I've extended some Ext classes and I wondered what's the right place to put the class configuration? This class configuration will be fixed for every new object.

This is the doubt:


App.view.HostsGrid = Ext.extend(Ext.grid.GridPanel, {

// config here?
height: 200,
width: 200,
...

constructor: function(config) {
...
}
});


or



App.view.HostsGrid = Ext.extend(Ext.grid.GridPanel, {

constructor: function(config) {
config = config || {};

Ext.applyIf(config, {

// config here?
height: 200,
width: 200,
...
});
}
});


Thanks in advance,

mitchellsimoens
8 Dec 2012, 6:41 AM
The first code snippet unless it's an object/array

fenderico
10 Dec 2012, 3:20 AM
The first code snippet unless it's an object/array

Thanks Mitchell.

I don't understand why you say 'unless it's an object/array'.

mitchellsimoens
10 Dec 2012, 6:06 AM
objects and arrays will be shared among instances producing unwanted behavior.

fenderico
10 Dec 2012, 9:12 AM
Thank you very much!