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
Greg MGreg M 

New and Need Help with putting data in columns

So I found the below code and wanted to modify it to meet my needs. The problem that I have is the records displayed in the apex:repeat do not get put in columns like in a apex:pageBlockTable. Other than that, it works fine. How do I modify the below code in order to get the desired result? Thank you in advance for your help!! 

FYI - I found the code here >>> https://blog.jeffdouglas.com/2011/03/02/dynamically-group-display-query-results/

 
<apex:page controller="DisplaySectionsController" action="{!load}" sidebar="false">
  <apex:sectionHeader title="My Sample Display Page" subtitle="Group by States" 
    description="This page shows how you can dynamically group results by field value."/>

  <apex:repeat value="{!states}" var="state">

    <apex:pageBlock title="{!state}">

      <apex:repeat value="{!accounts}" var="account"> 
 
        <apex:outputPanel rendered="{!IF(state=account.BillingState,true,false)}">
        {!account.Name} - {!account.BillingState}<br/>
        </apex:outputPanel>

      </apex:repeat>

    </apex:pageBlock>

  </apex:repeat>

</apex:page>
Best Answer chosen by Greg M
Maharajan CMaharajan C
Hi Greg,

Please try the below code and let me know if you need any changes:
 
<apex:page controller="DisplaySectionsController" action="{!load}" sidebar="false">
  <apex:sectionHeader title="My Sample Display Page" subtitle="Group by States" 
    description="This page shows how you can dynamically group results by field value."/>

  <apex:repeat value="{!states}" var="state">

    <apex:pageBlock title="{!state}">
    
     <table border = "1" cellpadding = "5" cellspacing = "5" >

        <tr>

            <th>Account Name</th>

            <th>Billing State</th>
        </tr>

        <apex:repeat var="account" value="{!accounts}">
        
        <apex:variable var="v" value="" rendered="{!IF(state=account.BillingState,true,false)}">
        
        <tr>
           
            <td> {!account.Name} </td>

            <td> {!account.BillingState} </td>

        </tr>
        
        </apex:variable>

        </apex:repeat> 

    </table>

    </apex:pageBlock>

  </apex:repeat>

</apex:page>

Thanks,
Maharajan.C