how fix this extjs layout?
This is my ext code
Ext.create('Ext.panel.Panel', {
title: 'Customer Information',
width: 300,
bodyPadding: 5,
floating: true,
renderTo: document.body,
frame: true,
collapsible: true,
closable: true,
defaults: { labelWidth: 90 },
items: [{
xtype: 'image',
id: 'profile_pic',
name: 'profile_pic',
style: { display: 'block', margin: 'auto' },
src: 'http://www.sencha.com/img/20110215-feat-html5.png',
},{
xtype: 'displayfield',
fieldLabel: 'ID',
name: 'viewer_id',
id: 'viewer_id',
padding: '5 0 0 0',
fieldCls: 'specialfield',
value: ''
},{
xtype: 'displayfield',
fieldLabel: 'Name',
name: 'viewer_name',
id: 'viewer_name',
fieldCls: 'fieldcolor',
value: '',
width: 280
},{
xtype: 'displayfield',
fieldLabel: 'Member ID',
开发者_如何学Python name: 'viewer_mem_id',
id: 'viewer_mem_id',
fieldCls: 'fieldcolor',
width: 280
},{
xtype: 'displayfield',
fieldLabel: 'Address',
name: 'viewer_address',
id: 'viewer_address',
fieldCls: 'fieldcolor',
width: 280
},{
xtype: 'displayfield',
fieldLabel: 'Phone [Home]',
name: 'viewer_phone_home',
id: 'viewer_phone_home',
fieldCls: 'fieldcolor',
width: 280
},{
xtype: 'displayfield',
fieldLabel: 'Phone [Mobile]',
name: 'viewer_phone_mobile',
id: 'viewer_phone_mobile',
fieldCls: 'fieldcolor',
width: 280
},{
xtype: 'displayfield',
fieldLabel: 'Phone [Work]',
name: 'viewer_phone_work',
id: 'viewer_phone_work',
fieldCls: 'fieldcolor',
width: 280
}]
});
problem is first time it loads it shows like this
once the image loaded and then refresh it gives me the layout i needed
i guess the problem is happening due to image size. how to fix this issue?
sorry for the bad english
Regards
Found the correct way to do it by adding a listener and bind load event to element
var v_profile_image = Ext.widget('image', {
src: '',
style: { display: 'block', margin: 'auto' },
name: 'profile_pic'
});
v_profile_image.on('load', function(e) {
this.up('panel').doLayout();
}, v_profile_image, { element: 'el' });
From the comments above.
If the height of image is not changing you can set the height of image: height:90
inside the declaring the image: jsfiddle.net/6NK7n/
Anyway, the image will be resized to fit the height you set.
精彩评论