ExtJS--10.5 Ext工具类 Ext.util.MixedCollection

<!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>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值