PDA

View Full Version : Render items such as combo box in to form panel



jfbk86
9 Jul 2012, 2:43 AM
I have created dynamic combo boxes in the form panel in the render event.
But couldnt make it render with in the form panel.

I have used the following techniques. But nothing worked out. Please help me.

renderTo: Ext.getCmp('formpanelid').getEl()

formpanelid.add(comboboxid);

Generally Html div element will be given in the render To. But still its not working for me.

Farish
9 Jul 2012, 2:53 AM
Instead of using ids of those components, try:


formpanel.add(combo);

sword-it
9 Jul 2012, 3:01 AM
hi jfbk86,

Also you need to call doLayout() method of formPanel after combobox added.


formPanel.add(combo);
formPanel.doLayout();

For more information see http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.Panel-method-doLayout

redraid
9 Jul 2012, 3:47 AM
See this example

Ext.create('Ext.form.Panel', {
itemId: 'myForm',
title: 'Simple Form',
bodyPadding: 5,
width: 350,
// The fields
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank: false
},{
fieldLabel: 'Last Name',
name: 'last',
allowBlank: false
}],
tbar: [{text: 'add combo', handler: function (btn) {
var form = btn.up('form');

form.add({
xtype: 'combobox',
fieldLabel: 'dynamic combo',
anchor: '100%',
// combobox config
});
}}],
renderTo: Ext.getBody()
});