简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM