+ Start a Discussion
Subhasini Bhosal 6Subhasini Bhosal 6 

to display two tables on a vf page and compare each row of the two tables and display the output

Any idea on how to display two tables on a vf page and compare each row of the two tables and display the output as matched or not matched on click of a button ?In the second table there should be a flag column that should be updated with true or false if any of the rows from two table match.

Thanks
JeffreyStevensJeffreyStevens
Well - there are a few questions to think about.  

What do you mean my "Match" - do you mean just one field in the two files match, several fields?  
Is one of the files the master?  Meaning - every record from the master would be listed on the left side, with no blanks on the left?  OR....
If there are records in table B that don't have matching Table A, should there be a blank line on the left side?

Even with some of those questions - I think you could do a series of maps to get what you needed. If you had maps that looked like this...

Set<String> masterKeys        // this would be a set of the keys from both files in the display order
map<string,FileA__c> mFileA      // This would be a map of the key to FileA, and the FileA record
map<string,FileB__c> mFileB      // This would be a map of the key to FileB, and the FileB record

Then in your controller - you could process the masterKeys set, and if mFileA containsKey, then the left side fields would be filled with the FileA info.  Also - check for mFileB and containsKey - and if there - fill in the right side fields.

Just one way on how to do it.