maephisto
maephisto

Reputation: 5182

Adding options to a selectfield ExtJS

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!

Upvotes: 0

Views: 558

Answers (1)

Ivan
Ivan

Reputation: 2262

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.

Upvotes: 1

Related Questions