Datagrid Matching/Compare help

i’ve been searching and trying for weeks on how to compare values of two seperate datagrids.

for example lets say i have a datagrid named mg_dg like this:

var myDP:Array = new Array ();
myDP.addItem ({id:1, firstName:"firstName_1", lastName:"lastName_1"});
myDP.addItem ({id:2, firstName:"firstName_2", lastName:"lastName_2"});
myDP.addItem ({id:3, firstName:"firstName_3", lastName:"lastName_3"});
myDP.addItem ({id:4, firstName:"firstName_4", lastName:"lastName_4"});
my_dg.dataProvider = myDP;

let say i have another datagrid named mg_dg2 like this:

var myDP2:Array = new Array ();
myDP2.addItem ({id:1, firstName:"firstName_1", lastName:"lastName_1"});
myDP2.addItem ({id:2, firstName:"firstName_2", lastName:"lastName_2"});
myDP2.addItem ({id:3, firstName:"firstName_3", lastName:"lastName_3"});
myDP2.addItem ({id:4, firstName:"firstName_5", lastName:"lastName_5"});
my_dg2.dataProvider = myDP2;

so if you noticed with my_dg2 that the there is firstName_5 and lastName_5 but there is not one in the my_dg datgrid.
if i were to select from my_dg2 firstName_5 and lastName_5…what i’m looking do is something along the lines of this:

var dgListener:Object = new Object ();
dgListener.cellPress = function (eObj:Object) {
		//if the selected row values from my_dg2 matches any of the row values in my_dg...
		trace("match found");
		trace("no match found");
		//proceed to do something else
mg_dg2.addEventListener ("cellPress",dgListener);

so it would output “no match found”.

i’ve even spent countless hours trying to hack this out:

this is sorta what i’d like to accomplish but not in the sense of using a textinput component.
it filters the datagrid of the text typed into the textinput component.

any help on how to achieve these results or could come up with a better more intuitive solution to this will greatly be appreciated.
thank you

Easy fix:

for(var i = 0; i<my_dg2.dataProvider.length; i++){
if(my_dg.getItemAt(i).firstName == my_dg2.selectedItem.firstName){
trace("match found!");
trace("no match found. :(");

It searches your whole datagrid for matching text. That code is not completely accurate, but should give you a lot of headway into your problem. Hope I helped. :wink:

thank you!!
i will give this a shot!!
again thanks!