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
SS KarthickSS Karthick 

Display list of Accounts

Hi folks,
 Can anyone tell me how to display list of all account_name in two column in VFP??

Thanks in advance
Karthick
Best Answer chosen by SS Karthick
praveen murugesanpraveen murugesan
Karthick,

Hope this will help you.

<apex:page controller="List_in_two_columns_Controller">
 <apex:form >
 <apex:variable value="{!1}" var="rowNum"/>
 <apex:pageBlock >
 
 
 <table >
 <apex:repeat value="{!accList}" var="item" >  
 <tr style=" width: 100%;text-align: right; border: 1px solid green;">
 <apex:outputField value="{!item.Name}" rendered="{!If(MOD(rowNum, 2)==0,true,false)}" > <tr></tr></apex:outputField>
   <apex:outputField value="{!item.Name}" rendered="{!If(MOD(rowNum, 2)!=0,true,false)}" ><br></br></apex:outputField>
 
    </tr>
    
  <apex:variable var="rowNum" value="{!rowNum + 1}"/>
</apex:repeat>  
</table>
 
 </apex:pageBlock>
 </apex:form>
</apex:page>

Controller:

public with sharing class List_in_two_columns_Controller
{
public list<account> getAccList()
{
    list<account> accList = [select id,name from account];
    return accList;
    

}
}

This will print acccount in two columns.

Mark this as best answer if its helps.

Thanks.

Praveen Murugesan

All Answers

Avidev9Avidev9
It should be pretty straight, never thought this kind of question can make it to the board !

<apex:page standardController="Account" recordSetVar="accounts" >
   <apex:pageBlock >
    <apex:pageBlockTable value="{!accounts}" var="acc">
      <apex:column value="{!acc.name}"/>
    </apex:pageBlockTable>
  </apex:pageBlock>
</apex:page>


SS KarthickSS Karthick
Hy Avidev9,
          Am asking to display all the account name in TWO column


Like This
Column1                 Column2
1st Acc.Name           2nd Acc.name
3rd                               4h



Please Help
praveen murugesanpraveen murugesan
Karthick,

Hope this will help you.

<apex:page controller="List_in_two_columns_Controller">
 <apex:form >
 <apex:variable value="{!1}" var="rowNum"/>
 <apex:pageBlock >
 
 
 <table >
 <apex:repeat value="{!accList}" var="item" >  
 <tr style=" width: 100%;text-align: right; border: 1px solid green;">
 <apex:outputField value="{!item.Name}" rendered="{!If(MOD(rowNum, 2)==0,true,false)}" > <tr></tr></apex:outputField>
   <apex:outputField value="{!item.Name}" rendered="{!If(MOD(rowNum, 2)!=0,true,false)}" ><br></br></apex:outputField>
 
    </tr>
    
  <apex:variable var="rowNum" value="{!rowNum + 1}"/>
</apex:repeat>  
</table>
 
 </apex:pageBlock>
 </apex:form>
</apex:page>

Controller:

public with sharing class List_in_two_columns_Controller
{
public list<account> getAccList()
{
    list<account> accList = [select id,name from account];
    return accList;
    

}
}

This will print acccount in two columns.

Mark this as best answer if its helps.

Thanks.

Praveen Murugesan
This was selected as the best answer