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
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 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>
User-added image
Swaraj Behera 7Swaraj Behera 7
Hi Dakshendra.
Can you please try below class and VF page.
Class:-
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 Integer numberOfcontact{get;set;} 
     
    
    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];
        numberOfcontact=cons.size();
         
    }       
}
VF 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="{!numberOfcontact}" 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>

Thanks,
Swaraj
 
SF DakshendraSF Dakshendra
Hi  Swaraj 
I tried above code  i ont get any change in that.For example if i have 9 contacts under same account it displays 3 coloumns and 3 rows.if i have three it just displays horizentally in 3 columns.
Thanks
Dakshendra.R