+ Start a Discussion
communitycommunity 

Apex redering Column problem Apex Data table

I rendering visualforce page as PDF. I am using data table to pull all the related lists into the VF page.

 

CRF__c is the main object. Address_Details__c is the child object (vlookup relation)

 

In a page block section called Address Details, there are 3 columns:

 

1) Address Type

2) Provide Post Code

3) Cease Post Code

 

If address type = Provide address, then only 1st and 2nd columns should be displayed.

If address type = Cease address, then only 1st and 3rd columns should be displayed.

 

For this, I am using output panel within the apex:columns. But its not working. If the condition satifies, the column header is missing in the output pdf.

 

 

<apex:pageBlock title="Address Details">
        <apex:dataTable value="{!CRF__c.Address_Details__r}" var="AD" columnsWidth="70px,70px" border="1" cellpadding="1">

<apex:column > <apex:facet name="header">Address Type:</apex:facet> <apex:outputText value="{!AD.Address_Type__c}"/> </apex:column> <apex:column> <apex:outputPanel rendered="{!AD.Address_Type__c=='Provide Address'}"> <apex:facet name="header" >Provide Post Code:</apex:facet> <apex:outputText value="{!AD.Provide_Post_Code__c}"/> </apex:outputPanel> </apex:column> <apex:column> <apex:outputPanel rendered="{!AD.Address_Type__c=='Cease Address'}"> <apex:facet name="header">Cease Post Code:</apex:facet> <apex:outputText value="{!AD.Cease_Post_Code__c}"/> </apex:outputPanel>
 </apex:column> </apex:dataTable> </apex:pageBlock>

 

Am i doing anything wrong. Please Help!!

 

 

Afzal MohammadAfzal Mohammad

Try moving rendered attibute from outputpanel to your outputtext tag.

 

 

<apex:outputPanel>
<apex:facet name="header" >Provide Post Code:</apex:facet>
<apex:outputText rendered="{!AD.Address_Type__c=='Provide Address'}"
value="{!AD.Provide_Post_Code__c}"/>
</apex:outputPanel>

 

 

Hope that helps.

 

Afzal

communitycommunity

No Change!

communitycommunity

The header of the column is missing while that column gets rendered.  Value is displaying though!

aballardaballard

I think there may be an issue where the column header rendering gets determined by the rendered attribute on the first row... i.e. if the first row has rendered=false for a given column, the header doesn't display.    

 

You could try an explicit rendered=true for the header facet and see if that helps.  

Sachin10Sachin10

Hi,

I'm also facing a similar problem...Any update or solution for the above problem?

Many thanks in advance for your help:-)

Bindhyachal Kumar SinghBindhyachal Kumar Singh
same issue here if any solution then reply
smoovbcaltexsmoovbcaltex

I ran into this problem (or a similar one) in which the columns and headers didn't seem to be obeying my rendered attribute.  I got unpredictable results: sometimes the column would be rendered, but not the header, or vice versa.

 

For me, the problem seemed to be that I was making the rendered attribute conditional on properties from the dataTable's var object.  When I changed to using a property from my controller, everything worked fine.

 

In retrospect, it makes some sense that column/header rendering didn't work when I was using a property from the var object.  How could a column or header, which apply to an entire table (a table either has a column or header or it doesn't), be rendered or not depending on a property from the var object, which could potentially vary for each row?

 

Hope this helps.