复制代码 代码如下:
public static function findRow(key:String,value:String,fromIndex:int,sourceArray:Array):int{
var resultIndex:int = -1;
if(sourceArray != null){
sourceArray.some(function findIndex(element:*,index:int,arr:Array):Boolean{
if(index >= fromIndex){
if(element == null){
if(value == null){
resultIndex = index;
return true;
}else{
return false;
}
}else{
if(StringUtil.Trim(element[key]) == StringUtil.Trim(value)){
resultIndex = index;
return true;
}else{
return false;
}
}
}else{
return false;
}
});
}
return resultIndex;
}
key 要搜索的object的键值 value 要搜索的object的value值 fromIndex从第几行开始搜索 sourceArray 要进行搜索的array
时间: 2024-10-31 06:47:40