<!DOCTYPE html>
<html>
<head>
<title>Ext.util.MixedCollection</title>
<meta name="content-type" content="text/html" charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../extjs4/resources/css/ext-all.css">
<script type="text/javascript" src="../extjs4/bootstrap.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
/** 1. add( key, [obj] ) : Object */
var item01 = new Ext.util.MixedCollection();
item01.add("01",{name:"a"});
item01.add("02",{name:"b"});
item01.add("03",{name:"c"});
item01.add("04",{name:"d"});
//alert(item01);
/** 2. addAll( objs ) */
var item02 = new Ext.util.MixedCollection();
var array = [];
array.push({name:"a"});
array.push({name:"b"});
array.push({name:"c"});
array.push({name:"d"});
var obj = {name:"e"};
array.push(obj);
item02.addAll(array);
//alert(item02);
/** 3. clear() */
var item03 = new Ext.util.MixedCollection();
item03.add("01",{name:"a"});
item03.add("02",{name:"b"});
item03.add("03",{name:"c"});
item03.add("04",{name:"d"});
item03.clear();
//alert(item03);
/** 4. clone( ) : Ext.util.MixedCollection */
var item04 = item01.clone();
// alert(item04);
/**
* 5. contains( o ) : Boolean
* 6. containsKey( key ) : Boolean
*/
//alert(item02.contains(obj));
//alert(item01.containsKey("01"));
/** 7. each( fn, [scope] ) */
var array02 = [];
item01.each(function(item){
array02.push(item.name);
});
//alert(array02.join(","));
/** 8. get( key ) : Object */
//alert(item01.get("02").name);
/** 9. first( ) : Object */
//alert(item01.first().name);
/** 10. add( index, o, key, eOpts ) */
item01.on("add",function(index, o, key){
alert("添加对象:\n"+"key:"+key+"\n"+"object:"+o+"\n"+"index:"+index);
});
item01.add("10",{name:"z"});
});
</script>
</head>
<body>
<div style="text-align: center;">
</div>
</body>
</html>