function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JamsieJamsie 

Visualforce: How to output repeating data to a fixed number of columns with wrapping?

Hi everyone,

I'm trying to output the contents of a wrapper class object based on a self-referncing heirarchy. I want to represent this in a fixed number of columns with additional items wrapping as follows:

User-added image

The wrapper is defined as:
 
public class CapabilityHierarchy {
        public  CapabilityHierarchy(Capability__c c){
            this.capability = c;
        }
        public Capability__c capability {get;set;}
        public List<CapabilityHierarchy> child_list {get;set;}       
    }

I have tried useing apex:repeat to render the levels but this leads to all output in a single cell when using an apex:pageblocksection or apex:panelgrid.  I've also tried using a span with defined width but this did not work either.

The markup for the basic output of the hierachies is detailed below.  Any help is much appreciated.
 
<apex:page standardController="Capability__c" extensions="CapabilitiesMatrixController" recordSetVar="capabilities"> 
    <apex:repeat var="ch1" value="{!hierarchy}">
        <h2>Level 1: {!ch1.capability.Title__c}</h2>
        <apex:repeat var="ch2" value="{!ch1.child_list}">  
            <apex:outputText value="Level 2: {!ch2.capability.Title__c}" styleClass=""/>
            <apex:repeat var="ch3" value="{!ch2.child_list}">
                <apex:outputText value="{!ch3.capability.Title__c}"/>
            </apex:repeat>
        </apex:repeat>
    </apex:repeat>          
</apex:page>

Thanks,
James.