简体   繁体   中英

Add/Remove Extjs combo value

I am newbie to extjs.I need to add/remove some values from extjs combo box base on some condition. I tried following code but no luck.

var obj =Ext.getCmp('filter');
                    var myArray=new Array();
                    myArray['id'] = 'a';
                    myArray['value'] = 'a';
                    var rec = new Ext.data.Record(myArray);
                    //obj.store.add(rec);

                    obj.store.removed(rec);
                    }

Use getById to find record for remove.

var combo = Ext.getCmp('filter');
combo.store.remove(combo.store.getById('a')); //typo: sotre corrected to store

combo.store.remove(combo.store.getById('a'));

obj.store.remove(rec);

removed is not a store function.

removed is a buffer array in which all removed recors are added.

if you're going to have a big store, you should keep this array empty, because removed objects are stored during all the session.

if the combo didn't change try to add store.sync() after adding or removing records

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