+ Start a Discussion
SF DakshendraSF Dakshendra 

HI i try this code for getting contact address information under account related list,its worked but i need the address information by only 3 coloums.if it has 4 contacts with same account the 4 th will be appeared in next row first colomn

HI i try this code for getting contact address information under account related list,its worked but i need the address information by only 3 coloums.if it has 4 contacts with same account the 4 th will be appeared in next row firstUser-added image colomn

Here my code is


public class getaddress

    public String obj;
    public account acc{get;set;}
    public List<contact> cons{get;set;}
    public id accid=apexpages.currentpage().getparameters().get('id'); 
     
    
    public getaddress() 
    {    
          
       acc=[select id,name from account where id=:accid];
        cons= [SELECT ID,Name,Mailingstreet,Mailingcity,Mailingcountry,Mailingstate,Mailingpostalcode FROM contact where accountid=:accid];
        
         
    }       
}


Visual page:

<apex:page controller="getaddress" renderAs="pdf" >

<apex:form>  
<apex:outputPanel layout="block" style="overflow:auto;height:190px;">



    
        <table width="100%" ><tr><apex:repeat value="{!cons}" var="u"><td width="100%" colspan="3" style="display:block;float:horizental">
                     
                      <apex:outputfield value="{!u.Mailingstreet}"></apex:outputfield><br/>

                     <apex:outputfield value="{!u.Mailingcity}"></apex:outputfield><br/>
                      <apex:outputfield value="{!u.Mailingstate}"></apex:outputfield><br/>
                      <apex:outputfield value="{!u.Mailingcountry}"></apex:outputfield>
                      <apex:outputfield value="{!u.Mailingpostalcode }"></apex:outputfield>
</td><br/></apex:repeat></tr></table>
</apex:outputPanel>

            
</apex:form>    
</apex:page>
VineetKumarVineetKumar
Try the below code :

PAGE
<apex:page controller="getaddress" renderAs="pdf" >
	<apex:form>  
		<apex:outputPanel layout="block" style="overflow:auto;height:190px;"> 
				<table>
                <apex:variable var="counter" value="{!0}"/>
                <apex:repeat value="{!cons}" var="row">
                    <tr>
                        <apex:repeat value="{!numberOfColumns}" var="column">   
                            <apex:outputPanel  rendered="{!IF(cons.size > (column + counter*numberOfColumns.size)-1, true, false)}">
                                <td>         
                                    <apex:outputfield value="{!cons[(column + counter*numberOfColumns.size)-1].Mailingstreet}"></apex:outputfield><br/>
									<apex:outputfield value="{!cons[(column + counter*numberOfColumns.size)-1].Mailingcity}"></apex:outputfield><br/>
									<apex:outputfield value="{!cons[(column + counter*numberOfColumns.size)-1].Mailingstate}"></apex:outputfield><br/>
									<apex:outputfield value="{!cons[(column + counter*numberOfColumns.size)-1].Mailingcountry}"></apex:outputfield>
									<apex:outputfield value="{!cons[(column + counter*numberOfColumns.size)-1].Mailingpostalcode }"></apex:outputfield>							
                                </td>
                            </apex:outputPanel>
                        </apex:repeat>
                        <apex:variable var="counter" value="{!counter+1}"/>
                    </tr>   
                </apex:repeat> 
		</apex:outputPanel>            
	</apex:form>    
</apex:page>
CONTROLLER

Create 1 getter setter variables :
public List<Integer> numberOfColumns {get; set;}

define there lists in constructor:
numberOfColumns = new List<Integer>{1, 2, 3};