<script type="text/javascript">
Ext.onReady(function() {
var panel = new Ext.Panel({
title : '集合调用Ext.each的处理',
renderTo : Ext.getBody(),
width : '280px',
html : "<div style='height:160px'></div>"
});
/**
遍历集合
*/
var array = [], i;//定义一个集合
for (i = 0; i < 10; i++) {//为集合添加元素
Ext.Msg.alert('','pushs');
array.push(i);
}
function fn(item, index, allItems) {//对集合元素追加字符串处理
if (item > 5) {
return false;
} else {
allItems[index] = item + "_st";
}
}
function fn1(item, index, allItems) {//打印集合处理函数、
if (index > 0)
return false;
Ext.Msg.alert('最后结果', "<div style='width:160px'>最后集合为:"
+ allItems + "</div>");
}
Ext.each(array, fn);
Ext.each(array, fn1);
});
</script>
Ext.onReady(function() {
var panel = new Ext.Panel({
title : '集合调用Ext.each的处理',
renderTo : Ext.getBody(),
width : '280px',
html : "<div style='height:160px'></div>"
});
/**
遍历集合
*/
var array = [], i;//定义一个集合
for (i = 0; i < 10; i++) {//为集合添加元素
Ext.Msg.alert('','pushs');
array.push(i);
}
function fn(item, index, allItems) {//对集合元素追加字符串处理
if (item > 5) {
return false;
} else {
allItems[index] = item + "_st";
}
}
function fn1(item, index, allItems) {//打印集合处理函数、
if (index > 0)
return false;
Ext.Msg.alert('最后结果', "<div style='width:160px'>最后集合为:"
+ allItems + "</div>");
}
Ext.each(array, fn);
Ext.each(array, fn1);
});
</script>