Check if selected record value exists in another listgrid?

Hi there,

Im trying to figure out how to make the following code more efficent.

I have two gridlists, one called myData and on called listData (different datasources). In listData when the onclick method is called it runs updateDetails function. What it then does is go through all the records of myData matching the selected record value against the ones in myData. If it matches it triggers the alert “match”.

The problem is as myData grows in records the time to loop through the records with increase. Is there a better way to match the values?

updateDetails : function () {
        var record = this.getSelectedRecord();
		for (i=0;i<=myData.data.localData.length-1;i++){
			if(myData.data.localData[i]['skill_name_id'] == record['skill_name_id']){
				alert('match');
				break;
			}
		}
},

I was thinking maybe if i define the localData record key as the value i could go:

if(myData.data.localData[[B]record['skill_name_id'][/B]]['skill_name_id'] ){
alert('match');
}

for example,

instead of:
myData.data.localData[0][‘skill_name_id’]
myData.data.localData[1][‘skill_name_id’]
myData.data.localData[2][‘skill_name_id’]

I could have

myData.data.localData[432][‘skill_name_id’]
myData.data.localData[464][‘skill_name_id’]
myData.data.localData[531][‘skill_name_id’]

Hi
We wouldn’t recommend iterating through the localData attribute of a ResultSet to find a property value - the find() method exists and should do the same thing more efficiently.

If you’re still having performance issues using this API let us know
Thanks
Isomorphic Software

Once again thankyou.

For anyone else this is how it was done:

updateDetails : function () {		
		var record = this.getSelectedRecord();
		var recordMatch=myData.data.find("skill_name_id",record['skill_name_id']);
		if(recordMatch != null){
			alert("Match");
		}
}