PDA

View Full Version : add combo box after creating form..



vishal.birari
9 Mar 2010, 2:34 AM
Hello,

I have following code :

Ext.onReady(function(){

Ext.QuickTips.init();

var movie_form = new Ext.FormPanel({
name: 'movie_form_id',
url: 'movie-form-submit.jsp',
renderTo: document.body,
frame: true,
title: 'Movie Information Form',
width: 250,
items: [
{
xtype: 'textfield',
fieldLabel: 'Title',
name: 'title'
},{
xtype: 'textfield',
fieldLabel: 'Director',
name: 'director',
vtype: 'name'
}
]
});

Now, I create combo box as follows and want to add it to above form:

var colorsStore = new Ext.data.SimpleStore({
fields: ['name'],
data: [['Blue'],['Red'],['White']]
});

var combo = new Ext.form.ComboBox({
store: colorsStore,
displayField: 'name',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
//applyTo: 'colors-combo',
emptyText: 'Select a color...',
selectOnFocus: true,
id: 'colors-combo'
});

I tried with following code, but no luck:

movie_form.add(combo);
movie_form.doLayout();
});

How can I add component (combo box in this case) to existing form?

vishal.birari
9 Mar 2010, 3:51 AM
removing " applyTo: 'colors-combo' " did not work. Pls help.

vishal.birari
9 Mar 2010, 9:31 PM
I myself happened to find out the solution to my problem...

add following line of code (1st two lines as it is) in existing onReady() function:

movie_form.add(combo);
movie_form.doLayout();
combo.render();
});

Note - remove or comment " applyTo: 'colors-combo' " entry from combo config for this to work.

Enjoy..

tryanDLS
10 Mar 2010, 11:17 AM
http://extjs.com/learn/Ext_Forum_Help#How_to_post_code_properly

Don't use polls to ask for help.