I have three list i.e, A, B,C. I want to display each list in a column of a table. Like column A will have values of list A. How do I do that? Thanks for any help!!!

for Example:

a[] listA = New List[]{"1","2',"3"};
b[] listB = New List[]{"4","5',"6"};
c[] listC = New List[]{"7","8',"9"};

I need to be able to display a table using each list as column values, for example:

COL A     COL B    COL C   
1         4        7   
2         5        8 
3         6        9

What would be the best approach to do this?


Suppose A B C are list<String>

Create a wrapper class with all 3 A, B, C String

public Class pageCtrl{
    public List<wrapper> lstWrapper {get;set;}

    public pageCtrl(){
    lstWrapper = new List<wrapper>();
    lstWrapper.add(new wrapper)

 public class wrapper{

    public String A {get;set;}
    public String B {get;set;}
    public String C {get;set;}

    public wrapper(String A, String B, String C){
       this.A = A;
       this.B = B;
       this.C = C;

VF page

<apex:page controller="pageCtrl">
         <apex:pageBlockTable value="{!lstWrapper}" var="wrpr">

  • In my scenario in wrapper class A, B, C are no string. Its a list and those list has to iterated as row. – SFDC Mafia - VIC Dec 27 '15 at 16:38
  • list of string. – SFDC Mafia - VIC Dec 27 '15 at 17:18
  • create one more wrapper class for A,B,C String and use this wrapper in first wrapper – Ratan Paul Dec 27 '15 at 17:25

There is a another way. You can simple create 3 tables inside one table in your VF page. By doing this you can avoid the processing over the collections to store the elements again in the List<wrapper>. Ex:

<table> //outerTable
<table></table> //table 1  -Use apex repeat for each <tr> to show element
<table></table> // table2
<table></table> //table3
</table> //end of outer table
  • Thanks man for your suggestion. I had figured it out earlier. :) – SFDC Mafia - VIC Jan 5 '16 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.