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
Manjunath SC 5Manjunath SC 5 

how to split the field value in the table in the visualforce page

Hello all

i am new to the vf, i am trying to populate the field values in a table format for the custom object, (i have not used Custom controllers)
how do i populate the field values in 2 columns like shown in the snapshot




below is my code

<apex:page standardController="Apartment__c" showHeader="false" renderAs="pdf" DocType="html">
<apex:form >
   <apex:pageBlock title="Appartment Details">
           <apex:pageBlockSection >
         <table style="width:100%">   
         <tr> 
          <td> <apex:outputField value="{! Apartment__c.Name }" /> </td>
          <td> <apex:outputField value="{! Apartment__c.Floor_No__c }"/> </td>
          <td> <apex:outputField value="{! Apartment__c.Phase__c }" /> </td>
         <td> <apex:outputField value="{! Apartment__c.Property_No__c }"/> </td>
         <td> <apex:outputField value="{! Apartment__c.Facing__c }" /> </td>
          <td> <apex:outputField value="{! Apartment__c.Terrace_Area_Cost__c }"/> </td>
          </tr> 
    </table>
    </apex:pageBlockSection>     
</apex:pageBlock>
</apex:form>
</apex:page>

it should show something like this
Ajay K DubediAjay K Dubedi
Hi Manjuntath,

You can use the below code: 
 
<apex:page standardController="Apartment__c" showHeader="false"  DocType="html">
    <head>
        <style>
            .table {
            border-collapse: collapse;
            width: 40%;
            }
            .td{
            border: 1px solid black;
            text-align: left;
            
            }
        </style>
    </head>
    <body>
        <table class='table'>   
            <tr > 
                <td class='td'> Name </td>
                <td class='td'><apex:outputField value="{! Apartment__c.Name }" /></td>
            </tr>
            <tr > 
                <td class='td'> Floor_No__c </td>
                <td class='td'> <apex:outputField value="{!Apartment__c.Floor_No__c  }" /> </td>
            </tr>
            <tr> 
                <td class='td'> Phase__c </td>
                <td class='td'> <apex:outputField value="{!  Apartment__c.Phase__c}" /> </td>
            </tr>
            <tr > 
                <td class='td'> Property_No__c </td>
                <td class='td'> <apex:outputField value="{! Apartment__c.Property_No__c }" /> </td>
            </tr>
            <tr > 
                <td class='td'> Facing__c  </td>
                <td class='td'> <apex:outputField value="{! Apartment__c.Facing__c  }" /> </td>
            </tr> 
            <tr > 
                <td class='td'> Terrace_Area_Cost__c  </td>
                <td class='td'> <apex:outputField value="{!  Apartment__c.Terrace_Area_Cost__c }" /> </td>
            </tr>
        </table>
    </body>
</apex:page>

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com





 
Deepali KulshresthaDeepali Kulshrestha
Hi Manjunath,
 
Try this code, it will show the data in table format.
<apex:page standardController="Contact" recordSetVar="contacts" >
        <apex:pageBlock title="Contacts View for Ambassadors">
            <apex:form >
                    <table border="1px" style="width:30%;  border-collapse: collapse;">
                        <apex:repeat value="{!contacts}" var="a" id="list">
                        <tr>
                            <td colspan="2">
                             Name
                            </td>
                            <td colspan="2">
                                {!a.name}
                            </td>
                        </tr>
                           <tr>
                                <td colspan="2">
                                    Phone
                                </td>
                            <td colspan="2">
                                {!a.Phone}
                            </td>
                           </tr>
                        </apex:repeat>
                    </table>
            </apex:form>
        </apex:pageBlock>

I suggest to visit this link, it will help you

https://developer.salesforce.com/forums/?id=906F0000000DEPAIA4

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
Manjunath SC 5Manjunath SC 5
Guys i was able to do this without the table format, when i do this with table attribute i get an error "
Error: <apex:pageBlockSectionItem> may have no more than 2 child components"

below is my code without the table

<apex:page standardController="Apartment__c" showHeader="false" renderAs="pdf" DocType="html" standardStylesheets="false"> <head> <style> table, th, td {   border: 1px solid black;   border-collapse: collapse; } </style> </head> <apex:form >                  <apex:pageBlock>                  <apex:pageBlockSection>                                    <table style="width: 100%;">         <tr>                  <td style="width: 50%;">                            <table>             <tr>           <td> <apex:outputField value="{! Apartment__c.Name }" /> </td>           </tr>            <tr>            <td> <apex:outputField value="{! Apartment__c.Floor_No__c }"/> </td>            </tr>              <tr>            <td> <apex:outputField value="{! Apartment__c.Phase__c }" /> </td>            </tr>              <tr>           <td> <apex:outputField value="{! Apartment__c.Property_No__c }"/> </td>           </tr>             <tr>           <td> <apex:outputField value="{! Apartment__c.Facing__c }" /> </td>           </tr>             <tr>            <td> <apex:outputField value="{! Apartment__c.Terrace_Area_Cost__c }"/> </td>           </tr>      </table>          </td>               <td style="width: 50%;">                    <table style="width:100%">             <tr>           <td> <apex:outputField value="{! Apartment__c.Appox_Amount__c }" /> </td>           </tr>            <tr>            <td> <apex:outputField value="{! Apartment__c.Basic_Rate_Per_Sqft__c }"/> </td>            </tr>            <tr>            <td> <apex:outputField value="{! Apartment__c.SFT__c }"/> </td>            </tr>             <tr>            <td> <apex:outputField value="{! Apartment__c.Floor_Rise_Charges_Per_Sqft__c }"/> </td>            </tr>            <tr>            <td> <apex:outputField value="{! Apartment__c.Total_Rate__c }"/> </td>            </tr>             <tr>            <td> <apex:outputField value="{! Apartment__c.Layout__c }"/> </td>            </tr>                        </table>                                 </td>                                   </tr>               </table>                                                      </apex:pageBlockSection>                  </apex:pageBlock>                   </apex:form> </apex:page>