如何使用extjs通过我的数组的键获取数组的对象值?

时间:2014-09-02 07:47:20

标签: arrays extjs

我有一个名为Array

的数组
Array = [{id:1, project_name:"Vrindavan", project_phase:"A", project_block:"B", project_unit:"1200.sqt", project_status:"active", project_rent:"52,000", project_maintenance:"mar"},
{id:2, project_name:"Nyanza", project_phase:"B", project_block:"A", project_unit:"1200.sqt", project_status:"active", project_rent:"52,000", project_maintenance:"mar"},
{id:3, project_name:"Rixi", project_phase:"C", project_block:"C", project_unit:"1200.sqt", project_status:"active", project_rent:"52,000", project_maintenance:"mar"}]

如何查找此数组的索引,其中id = 2 ....?

1 个答案:

答案 0 :(得分:-1)

请尝试以下代码

                 var flag=false;
                 for(var i=0;i< arr.length;i++){
                    var temp=   Ext.Object.getKey(arr[i],2);
                    if(temp=='id'){ 
                         return i;

                      }
                    }

我测试了它。它正在工作。希望这可以帮助你。