When I define a view class, I have to set a lot of repeated configs for child components.
Here is an example:
Ext.define('TEST.view.transaction.TransactionEditor', {
extend: 'Ext.form.Panel',
...
items: [{
...
labelWidth:80,
width: 230,
tdAttrs: { style: 'padding: 10px 20px 10px 20px;' },
...
},{
...
labelWidth:80,
width: 230,
tdAttrs: { style: 'padding: 10px 20px 10px 20px;' }
...
},
...
],
...
}
As you can see, the labelWidth, width and style are repeated several times. I want to use some constants or variables instead of these magic numbers. What is the proper way to do it in EXTJS?
UPDATE: The following two methods do not work well.
Using defaults is working for labelWidth and width, but does not work for tdAttrs.
By using the initComponent method, the component stopped displaying.
initComponent:function() {
var tdAttrs = { style: 'padding: 10px 20px 10px 20px;' }; Ext.apply(this,{ items:[{ tdAttrs:tdAttrs }]} ); this.callParent(arguments); },
Aucun commentaire:
Enregistrer un commentaire