How To Set Displayfield Width After setValue()?

Posted By Vitalii | March 22, 2012 | ExtJS 4.0.7
0 2652
Reply to thread

Js Code

Ext.create('Ext.panel.Panel', {
	width: 400,
	height: 150,
	tbar: [
		{
			xtype: 'displayfield',
			id: 'displayfield-id-1',
			value: 'displayfield #1'
		},
		{
			xtype: 'tbseparator'
		},
		{
			xtype: 'displayfield',
			id: 'displayfield-id-2',
			value: 'displayfield #1'
		}
	],
	bbar: [
		{
			text: '1. Change Value (does not work)',
			handler: function () {
				var field = Ext.getCmp('displayfield-id-1');
				var tbar = field.up('toolbar');
				field.setValue('long long text blablabla');
				tbar.doLayout();
			}
		},
		{
			text: '2. Recreate Item (works fine)',
			handler: function () {
				var field = Ext.getCmp('displayfield-id-1');
				var tbar = field.up('toolbar');
				tbar.remove(field, true);
				tbar.insert(0, Ext.widget('displayfield', {
					id: 'displayfield-id-1',
					value: 'long long text blablabla'
				}));
			}
		}
	],
	renderTo: 'output'
});