+ Start a Discussion

how to create wrapper class to display survey results

I have query results coming as following: for contact 1 for three questions and answers.


for Contact 1

 Q1  - ans1

 Q2 - ans2

  Q3 - ans3


for Contact 2

 Q1  - ans1

 Q2 - ans2

  Q3 - ans3

I want to dislay the above results as following:

       Q1    Q2    Q3

C1   ans1 ans2 ans3

C3   ans1 ans2 ans3

 can someone please help me create a class in my controller that help create this display in my apex page? How to display column values as row hearders..


I really appreciate any suggestions?




You need to create 3 wrapper classes here, which look like something like this (at a high level):



public class ContactRows{ Map<Contact, Questions> cqMap; //Keep adding all the contacts in this with objects of questions.}public class Questions{ Map<Question__c, Answers> qaMap; Same as cqMap, add Questions and answers in this map}public class AnswerCells{ Add the answers.}


 I have done many applications like this where matrix of data has to be displayed. If this doesnt solves your problem, mail me directly i'll send you the complete sample code.





GreatG ,

thanks for the suggestion. But I could not figure out how to display value in the page.

I do not know how to use the map in the visual force page.


which class do I use to display results on page?

Message Edited by fromSEA on 03-29-2010 08:49 AM

Please send me code to disply table as mentioned above.Plz






Varun Gupta


Hello GreatG,


I am also facing sam problem as mentioned. Will you pls send me the code for the same as you mention in your reply...



Thanks In advance.