Looking at the extjs source code, we found that there are many mixedcollections. It is a collection class that contains both a digital index and a key, and exposes related events. It is equivalent to map and list in Java, and has four events: add element, remove element, replace element, clear set clear
(1) Let's see how it works.
1 // General Method
2 var MC = new Ext. util. mixedcollection ();
3 MC. Add (someel. Dom. ID, someel );
4 MC. Add (otherel. Dom. ID, otherel );
5 // and so on
6
7 // use getkey
8 var MC = new Ext. util. mixedcollection ();
9 MC. getkey = function (EL ){
10 return El. Dom. ID;
11 };
12 MC. Add (someel );
13 MC. Add (otherel );
14
15 // or through the constructor
16 var MC = new Ext. util. mixedcollection (false, function (EL ){
17 return El. Dom. ID;
18 });
19 MC. Add (someel );
20 MC. Add (otherel );
1 // General Method
2 var MC = new Ext. util. mixedcollection ();
3 MC. Add (someel. Dom. ID, someel );
4 MC. Add (otherel. Dom. ID, otherel );
5 // and so on
6
7 // use getkey
8 var MC = new Ext. util. mixedcollection ();
9 MC. getkey = function (EL ){
10 return El. Dom. ID;
11 };
12 MC. Add (someel );
13 MC. Add (otherel );
14
15 // or through the constructor
16 var MC = new Ext. util. mixedcollection (false, function (EL ){
17 return El. Dom. ID;
18 });
19 MC. Add (someel );
20 MC. Add (otherel );
(2) Add and call the add method. The addall method is used to add an array or object. IfallowFunctions
SetTrue, Then the function reference will also be added to the set.
(3) four methods are used for the value. The item method returns the project bound to the passed key or index. The key has a higher priority than the index. This is equivalent to calling the key first, and then calling itemat if there is no project match. That is, their priority is item (String/Number key
), Key (String/Number key
)-> Get (Number index
)-> Itemat (Number index
)
(4) common methods such as each, contains, and remove