View Full Version : Merge MixedCollections?

5 Dec 2011, 2:02 AM
Hi all!

My question is quite simple yet I haven't found the desired function in ExtJS.
Is there a way to merge two (or more) MixedCollections? That is have a result collection that contains items belonging to both source collections?

5 Dec 2011, 4:42 AM
I do not see that function is available, but it is easy I think to implement yourself. Its possible to iterate both collections and add the items to a newly created collection.

5 Dec 2011, 10:54 PM
Ext.util.MixedCollection is very similar to array object. It has structure like ['key', 'item']. You can iterate one collection and add second to it

var coll = new Ext.util.MixedCollection();
var coll2 = new Ext.util.MixedCollection();

coll.add('key1', 100);
coll.add('key2', -100);
coll.add('key3', 17);
coll.add('key4', 0);

Ext.Array.each(coll.items, function(item, key){
coll2.add(key, item);

5 Dec 2011, 11:22 PM
tvanzoelen, icemanovich thanks for replies!
I just thought ExtJS already has a similar method out-of-the box. By the way it would be interesting to implement set-theoretical operations fot MixedCollections :)

Question closed...