I understand that this needs to be done using the infamous wrapper class, but for some reason I am not able to get it to work. Any help would be great.
Goal: Display multiple List<String>
as columns.
Something like this:
I would like to use pageblockTable to accomplish this (or perhaps a pageblockTable within a pageblockTable).
I am storing each column data in a List<String>
and it does NOT have a fixed number of entries. Each such List<String>
needs to repeat as columns for as many years as specified by user input.
public class Summary{
public List<String> summary_list {get; set;}
public Summary(List<String> s){
summary_list = s;
}
}
public List<Summary> summary_list_wrap {get; set;}
public List<String> items_in_column {get; set;}
public void build_Table(){
//populating the data here - which is working as per the screenshot below
}
The values of summary_block_wrap look like this when printed using the below code:
<apex:pageblockTable value="{!summary_list_wrap}" var="slw">
<apex:column value="{!slw}"/>
</apex:pageblockTable>
How do I tweak my visualforce page to match the desired layout?
EDIT: After implementing the answer suggested by Ashwani, the output looks like below. How can we format the table to remove the spacing between the columns and trim the column widths?
Best Answer
You should create a 2 dimensional array or we can say List of List which looks like
List<List<String>> twoDimArray
and try to iterate it like:Here you will have to arrange the collection properly. Possible iteration can be:
OP ADDED OUTPUT:
I would like the output table style to look like that of pageblockTable. But is there a way to get rid of the spacing between the columns? And why is the last column squeezed as opposed to others? I would like to have a 'space trimmed' table instead of something with 100% width and wide spaces in between. How?