+ Start a Discussion
DevSFDevSF 

How to Hide a table in Visualforce Page

Hi 
I am creating a pdf of Invoice Page. Now I want to hide some fields on table on pdf depending on picklist value (Rating__c).

I have created a table which denotes the Quantity,Name,Price,Total On the PDF Page.
This is My Table. :


 <table cellpadding="2" cellspacing="0" style="width:100%;">
                    <tr style="font-size:16px;height:32px;Font-family:Verdana,Arial;" >  

                        <td style="width:7%;background-color:#707070;border-left:1px solid;border-top:1px solid;border-right:none;border-bottom:1px solid;text-align:center;">Quantity</td>
                        <td style="width:15%;background-color:#707070;border-left:1px solid;border-top:1px solid;border-right:1px solid;border-bottom:1px solid;text-align:center;">Item</td>                        
                        <td style="width:27%;background-color:#707070;border-left:none;border-top:1px solid;border-right:1px solid;border-bottom:1px solid;text-align:center;">Description</td> 
                        <td style="width:12%;background-color:#707070;border-left:none;border-top:1px solid;border-right:1px solid;border-bottom:1px solid;text-align:center;">Unit Price</td>
                        <td style="width:12%;;background-color:#707070;border-left:none;border-top:1px solid;border-right:1px solid;border-bottom:1px solid;text-align:center;">Total</td>   

                    </tr> 
                    <apex:repeat value="{!retriveInvoiceInfo}" var="inv" id="theRepeat"> 
                
                    <tr style="font-size:16px;height:300px;vertical-align:text-top;Font-family:Verdana,Arial;"> 
                        <td style="border-left:1px solid;border-top:none;border-right:none;border-bottom:none;text-align:center;"><apex:outputText value="{!invoiceData.Quantity__c}"/></td>
                        <td style="border-left:1px solid;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="${!unitprice}" rendered="{!IF(unitprice==NUll || unitprice==0,false,true)}"/></td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="{!inv.Product_Name_del__c}"/></td>           
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="{!orderDiscount}" /></td> 
                        <td style="border-left:0.1px solid;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="${!inv.Total_Amount_In_INR__c}" rendered="{!IF(inv.Total_Amount_In_INR__c==NUll || inv.Total_Amount_In_INR__c==0,false,true)}"/></td> 
                    </tr> 
                        
                    <tr style="font-size:16px;height:18px;Font-family:Verdana,Arial;">
                        <td style="border-left:none;border-top:1px solid;border-right:none;border-bottom:none"></td>                        
                        <td style="border-left:none;border-top:1px solid;border-right:none;border-bottom:none"> </td> 
                        <td style="border-left:none;border-top:1px solid;border-right:1px solid;border-bottom:none"> </td>           
                        <td style="border-left:none;border-top:1px solid;border-right:1px solid;border-bottom:1px solid;text-align:right;" >Subtotal</td> 
                        <td style="border-left:none;border-top:1px solid;border-right:1px solid;border-bottom:1px solid;text-align:center;"><apex:outputText value="${!inv.Subtotal_in_INR__c}" rendered="{!IF(inv.Subtotal_in_INR__c==NUll || inv.Subtotal_in_INR__c==0,false,true)}"/></td> 
                    </tr>
                   
                   <tr style="font-size:14px;height:14px;Font-family:Verdana,Arial;">
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"></td>                         
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"></td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none"></td>             
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:right;">ServiceTax </td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:center;"><apex:outputText value="${!inv.Indian_Service_Tax_Amount__c}" rendered="{!IF(inv.Currency__c=='INR' || inv.Indian_Service_Tax_Amount__c==0,false,true)}"/></td> 
                    
                    </tr>
                        
                        <tr style="font-size:14px;height:14px;Font-family:Verdana,Arial;">
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"></td>                         
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"></td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none"></td>             
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:right;">Excise tax</td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:center;"><apex:outputText value="${!inv.Swachh_Bharat_Cess__c}" rendered="{!IF(inv.Swachh_Bharat_Cess__c==NUll || inv.Swachh_Bharat_Cess__c==0,false,true)}"/></td> 
                    </tr>
                        
                    <tr style="font-size:14px;height:14px;Font-family:Verdana,Arial;">
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"></td>                         
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"> </td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none"></td>             
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:right;"><b>Total Amount</b></td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:center;"><apex:outputText value="${!inv.Total_Amount_In_INR__c}" rendered="{!IF(inv.Total_Amount_In_USD__c==NUll || inv.Total_Amount_In_USD__c==0,false,true)}"/></td> 
                    </tr>
                        
                    <tr style="font-size:14px;height:14px;Font-family:Verdana,Arial;">
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"></td>                         
                        <td style="border-left:none;border-top:none;border-right:none;border-bottom:none"> </td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none"></td>             
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:right;"><b>Paid</b></td> 
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:1px solid;text-align:center;"><apex:outputText value="${!inv.Total_Amount_In_INR__c}" rendered="{!IF(inv.Total_Amount_In_USD__c==NUll || inv.Total_Amount_In_USD__c==0,false,true)}"/></td> 
                    </tr>
                    
                    </apex:repeat> 
                   
                </table>
                
             
        </td>


In the above code i have highlighted the two fields that i want to hide when picklist value is changed.

How to achieve this...?

Can anyone help me out of this....!
Mahesh DMahesh D
Hi,

Please try to use the below code:
 
<apex:outputPanel rendered="{!If(picklistField=='tax',true,false)}">
Your Table
</apex:outputPanel>

Regards,
Mahesh
Mahesh DMahesh D
Hi,

Please try to use the below code:
 
<apex:outputPanel rendered="{!If(picklistField=='tax',true,false)}">
Your Table
</apex:outputPanel>

Regards,
Mahesh
DevSFDevSF
Thank You mahesh.

And I have one more doubt in my page :

I have two custom objects 
1)  Invoice__c
2) Invoice_Product__c

These 2 objects have master detail relationship between them (Invoice_Product__c is child object)

Here, i am writing a visualforce page on parent object (Invoice__c) where i need to get the values of my child object (Invoice_Product__c).

My Page : 

<apex:repeat value="{!Invoice__c}" var="inv" id="theRepeat"> 
                
                    <tr style="font-size:16px;height:300px;vertical-align:text-top;Font-family:Verdana,Arial;"> 
                        <td style="border-left:1px solid;border-top:none;border-right:none;border-bottom:none;text-align:center;"><apex:outputText value="{!inv.Quantity__c.Invoice_Product__r}"/></td>
                      
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="{!inv.Product_Name_del__c.Invoice_Product__r}"/></td>           
                        <td style="border-left:none;border-top:none;border-right:1px solid;border-bottom:none;text-align:center;"><apex:outputText value="{!inv.orderDiscount.Invoice_Product__r}" /></td> 

The Highlighted fields are from child object (Invoice_Product__c)

The error i was geeting was ::

  "Unknown property 'Integer.Invoice_Product__r'

How do I get the fields of (Invoice_Product__c) on my page.
 
Mahesh DMahesh D
Hi,

Generally you can get all the Child records by using the Child Relationship Name, for example

{!Account.Contacts} it will print all the related contacts for the given Account.

If you Iterate this list then you can get all the corresponding contacts along with each field value.

Similarly, in your case, you have to use the RelationshipName to get the list of child records, from that you can print each individual child object values.

Please check the below example:
 
<apex:page standardController="Account">
   <apex:form >
       <apex:pageBlock title="List of Contacts">
           <apex:pageBlockTable value="{!Account.Contacts}" var="con">
               <apex:column value="{!con.Name}"/>
               <apex:column value="{!con.Title}"/>
               <apex:column value="{!con.Email}"/>
               <apex:column value="{!con.Phone}"/>
           </apex:pageBlockTable>
       </apex:pageBlock>
	</apex:form>
</apex:page>

Please do let me know if it helps you.

Regards,
Mahesh