我有一个名为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 ....?
答案 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;
}
}
我测试了它。它正在工作。希望这可以帮助你。