christythomas
24 Jan 2011, 12:24 PM
I'm having trouble adding multiples of my own registered xtypes to a panel. If I use my new registered xtype then I only get the last one added to the items array. If I switch them to xtype: 'panel' then it works as I expect. What could be wrong with my 'displayfield' registered type?
This is the code that creates the panel with multiple 'displayfield' xtypes used.
{
xtype: 'panel',
id: 'exec-views-informationsection-info',
style: 'background-color: #696969',
layout: {
type: 'vbox',
align: 'stretch',
pack: 'end'
},
defaults: {
xtype: 'displayfield',
//xtype: 'panel',
//html: 'test',
flex: 1,
style: 'font-size: 60%'
},
items: [
{
title: 'High',
value: '423'
},{
title: 'Low',
value: '3'
},{
title: 'Average',
value: '192'
},{
title: 'Last Update',
value: '16:21'
}
]
}
This is the code that defines the 'displayfield'.
views.DisplayField = Ext.extend( Ext.Panel, {
value: 'Unknown Value',
id: 'views-displayfield',
defaults: {
padding: 10
},
initComponent: function(){
Ext.apply(this, {
items: [{
layout: {
type: 'hbox',
pack: 'top'
},
items: [{
html: this.title,
flex: 2
}, {
html: this.value,
style: 'text-align: right;',
flex: 1
}]
}]
});
views.DisplayField.superclass.initComponent.call(this);
}
});
Ext.reg('displayfield', views.DisplayField);
This is the code that creates the panel with multiple 'displayfield' xtypes used.
{
xtype: 'panel',
id: 'exec-views-informationsection-info',
style: 'background-color: #696969',
layout: {
type: 'vbox',
align: 'stretch',
pack: 'end'
},
defaults: {
xtype: 'displayfield',
//xtype: 'panel',
//html: 'test',
flex: 1,
style: 'font-size: 60%'
},
items: [
{
title: 'High',
value: '423'
},{
title: 'Low',
value: '3'
},{
title: 'Average',
value: '192'
},{
title: 'Last Update',
value: '16:21'
}
]
}
This is the code that defines the 'displayfield'.
views.DisplayField = Ext.extend( Ext.Panel, {
value: 'Unknown Value',
id: 'views-displayfield',
defaults: {
padding: 10
},
initComponent: function(){
Ext.apply(this, {
items: [{
layout: {
type: 'hbox',
pack: 'top'
},
items: [{
html: this.title,
flex: 2
}, {
html: this.value,
style: 'text-align: right;',
flex: 1
}]
}]
});
views.DisplayField.superclass.initComponent.call(this);
}
});
Ext.reg('displayfield', views.DisplayField);