+ Start a Discussion

dataTable conditionally display column header

Can you only show a column header if the rows have data in them?  In the code below we don't want to display FOB if they can't view that column.


<apex:pageBlockTable value="{!priceListCanada}" var="p"> <apex:column > <apex:facet name="header"> <apex:outputText value="FOB" /> </apex:facet> <apex:outputText value="{!p.FOB__c}"/> </apex:column>





    <apex:outputText value="FOB" rendered="{!p.FOB__c=''}" />


Nope, that's not it.

You can do it in a controller extension in your visualforce page

<apex:page standardController="YourObject__c" extensions="myPageController" recordSetVar="priceListCanada">

and a property


<apex:outputText value="FOB" rendered="{!FOBDisplay}" />

Then an apex class


public class myPageController {

private YourObject__c p ;
public Boolean FOBDisplay { get; set; }

    public myPageController(ApexPages.StandardSetController controller) {
        p = (YourObject__c) controller.getRecord() ;
        if (p.FOB__c == null)
          {FOBDisplay = false;}
          {FOBDisplay = true;}

Fill in your own values for "YourObject__c" and "myPageController"


Colin, thanks for taking the time to reply again but I don't think that will work either.  The problem is I'm doing this for our product search and the fields we are having problems with are on a custom related list for pricing.  It worked when we used the standard <apex:detail> but the business wanted to pricing related lists to be before the standard detail.