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
DarrellDDarrellD 

Conditionally Render PageBlock Table Rows?

Somewhat new to VF but not SF. 

 

Have a pageBlockTable and I'm trying to conditionally render a row based on record type.  So if recordtype = X, then render the row.

Is this the right approach or is something better?  Not having luck figuring out way to do this aside from put a render statement for each column, which can't be correct.

 

 

<apex:pageBlock rendered="{!$ObjectType.EntityAddress__c.accessible}" title="Location Addresses">

 

<!-- Been trying to add the render statement to line below? So if record type is X then render that row else do not -->

<apex:pageBlockTable value="{!contact.provideraddresses__r}" var="provideraddress">

 

<apex:column headerValue="Is Active" value="{!provideraddress.Active__c}"/>

 

<apex:column headerValue="Type" value="{!provideraddress.Address_Type__c}"/>

 

<apex:column headerValue="Street" value="{!provideraddress.Address__r.Address_Line_1__c} {!provideraddress.Address__r.AddrLn2__c}"/>      

 

<apex:column headervalue="City" value="{!provideraddress.Address__r.City__c}"/>

 

<apex:column headervalue="State" value="{!provideraddress.Address__r.State__c}"/>

</apex:pageBlockTable>

</apex:pageBlock>

 

D

Best Answer chosen by Admin (Salesforce Developers) 
TheSwamiTheSwami

I don't think column will work, but repeat might.

 

<apex:page controller="repeatCon" id="thePage">

    <apex:repeat value="{!strings}" var="string" id="theRepeat">

        <apex:outputText value="{!string}" id="theValue" rendered="{!string!='TWO'}"/><br/>

    </apex:repeat>

</apex:page>

 

public class repeatCon {
    public String[] getStrings() {
        return new String[]{'ONE','TWO','THREE'};
    }
}

 

 

This example will print out the list except for the "TWO" - You could probably adapt this format to what you are trying to do.  It may not work exactly with tables, but divs or ul/li would definitely work.