PDA

View Full Version : dynamic dropdown in extjs.



vinaykimi
26 Jan 2011, 3:07 AM
Hi ,
I want to have dynamic combobox whose values are populated based on the selection of other combobox.
I wrote the code like this.

new Ext.form.ComboBox({
fieldLabel: 'User type',
hiddenName:'user_type',
editable: false,
store: new Ext.data.ArrayStore({
fields: ['id', 'value'],
data :[[1,'user'],[2,'group']]
}),
valueField:'id',
displayField:'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'',
listeners: {
select: {

fn:function(combo, value) {
//console.log(formPanel);
// formPanel.usersStore(value.data.id);
user_store = taskAS.users.allUsers;

}

}
},
forceSelection:true,
selectOnFocus:true,
allowBlank: false,
width:190
}),
new Ext.form.ComboBox({
fieldLabel: 'Users',
hiddenName:'users',
store:user_store,

fay
26 Jan 2011, 4:12 AM
An example of how to do this is in the FAQs: http://www.sencha.com/learn/Ext_FAQ_ComboBox#linked_comboBoxes

vinaykimi
26 Jan 2011, 5:37 AM
I am trying to load static/local data in linked comboboxes , which loads the data in one combobox when other combox is changed.
The examples given are using proxy method, using ajax request.

I want to know how to change the store of one combobox , when other combox box is changed.

listeners: { select: {

fn:function(combo, value) {
//console.log(formPanel);
//formPanel.usersStore(value.data.id);
//user_store = taskAS.users.allUsers;
var modelCmp = Ext.getCmp('ext-comp-1018'); // getting the id of other combobox
modelCmp.store=[["v","vinay"],["k","kimi"]]; // changing the value of that combobox.
}

}
},

The above code is not working.

fay
26 Jan 2011, 8:01 AM
Take a look at Ext.data.Store's loadData (http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.Store&member=loadData) method. Also, to make it easier to read, can you post your code in CODE tags (and remove your commented out lines.)