本文地址:http://blog.csdn.net/sushengmiyan/article/details/39009555
sencha官方API:http://docs.sencha.com/extjs/5.0/apidocs/#!/api/Ext-method-each
本文作者:sushengmiyan
------------------------------------------------------------------------------------------------------------------------------------
看一下官方的介绍:
Iterates an array or an iterable value and invoke the given callback function for each item.
遍历全部能够循环的数组或者可迭代变量,而且运行给定的回调函数来处理每个成员。
有一个简单的数组的样例例如以下:
var countries = ['Vietnam', 'Singapore', 'United States', 'Russia'];
Ext.Array.each(countries, function(name, index, countriesItSelf) {
    console.log(name);
});
var sum = function() {
    var sum = 0;
    Ext.Array.each(arguments, function(value) {
        sum += value;
    });
    return sum;
};
sum(1, 2, 3); // returns 6Ext.each is alias for Ext.Array.each//Ext.each方法是ext.Array.each的别名。
參数介绍:
iterable :就是你要进行迭代的object。假设不可循环,就仅仅运行一次了。fn:回调函数。当遍历一次的时候就运行一次,函数包括三个參数
item。就是每次遍历的值
index,当前值的序号index
allItems:就是当前的数组对象本身。
返回值:
当想结束的时候就返回false就能够了。
实例演示:
1.使用cmd生成一个默认的程序
2.在\app\view\main目录下的MainController.js中改动onClickButton方法。
例如以下:
onClickButton: function () {
        //Ext.Msg.confirm('Confirm', 'Are you sure?', 'onConfirm', this);
	var StudentsJSON = {  
	  student:[{  
	    name: '张三',  
	    studentid: 200801,  
	    grade: 80  
	  },{  
	    name: '李四',  
	    studentid: 200802,  
	    grade: 90  
	  },{  
	    name: '王五',  
	    studentid: 200803,  
	    grade: 90  
	  },{  
	    name: '李二麻子',  
	    studentid: 200804,  
	    grade: 90  
	  }]  
	}; 
    Ext.each(StudentsJSON.student, function(student, index) {
		alert(student.name);
        if (student.studentid == '200803') {
			alert('下一个是李二麻子。可是我不让他显示了');
            return false; // 这里设置出口
       }});
    }显示效果例如以下:
点击button之后:
最后是:
[ExtJS5学习笔记]第十三节 Extjs5的Ext.each方法学习
原文:http://www.cnblogs.com/wzjhoutai/p/7364532.html