简体   繁体   English

添加/删除Extjs组合值

[英]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. 我是extjs的新手,我需要在某些条件下从extjs组合框中添加/删除一些值。 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. 使用getById查找要删除的记录。

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

combo.store.remove(combo.store.getById('a')); 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. remove是一个缓冲区数组,其中添加了所有删除的记录器。

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 如果组合没有更改,请尝试在添加或删除记录后添加store.sync()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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