Adding options to a selectfield ExtJS

Go To StackoverFlow.com

0

I have a form with two selectfields. I would like that when something is selected from the first select box, to be able to add some option in the second one.

Here's the code for the second one :

xtype: 'selectfield',
       id: 'category_id',
       name: 'category_select',
       label: 'Categoria',
       options: [{
                    text: 'test',
                    value: '1'
                 },{
                    text: 'test2',
                    value: '2'
                }]

I've tried with

Ext.getCmp('category_id').add("test3");

but it doesn't work. Can you please help me? Thanks!

2012-04-04 08:29
by maephisto


1

Ext.getCmp('category_id').getStore().loadData(data, true);

Data is array of records (objects). Second parameter is append. When is true data will be appended to store. In other case store data will be replaced with new one. By default is false.

2012-04-04 08:46
by Ivan
Thanks @Ivan ! what kind of objects should be in the data array - maephisto 2012-04-04 09:25
Also, I get this error message on the line you specified: Uncaught TypeError: Object [object Object] has no method 'getStore - maephisto 2012-04-04 09:59
Ext.getCmp('category_id') returns Ext.form.field.ComboBox, isn't it - Ivan 2012-04-04 10:38
Ads