Conditional Rendered Expression

Syntax:

rendered="{! condition, true, false)}" 

Sample Code:


<apex:page controller="sample">
    <apex:pageBlock >
    <apex:variable var="i" value="{!0}"/>
        <apex:pageBlockTable value="{!acnt}" var="acc">
            <apex:column >
                <apex:variable var="i" value="{!i+1}"/>
            </apex:column>
            <apex:column value="{!acc.Name}" rendered="{! IF((mod(i,2)) == 0, true, false)}" style="background:pink;"/>
            <apex:column rendered="{! IF((mod(i,2)) == 0, true, false)}" style="background:pink;" value="{!acc.Rating}"/>                     
           
            <apex:column value="{!acc.Name}" rendered="{! IF((mod(i,2)) == 1, true, false)}" style="background:yellow;"/>
            <apex:column rendered="{! IF((mod(i,2)) == 1, true, false)}" style="background:yellow;" value="{!acc.Rating}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>


Cheers!!!

1 comment:

  1. How would you structure your statement if you wanted to base your rendering off of the user's Permission Set Assignment? I have a VF page that is serving as a dashboard that displays different object records in a panel grid based on their permission set assignment. I am using the permission set label name they are assigned as the basis but must cross several objects to get there (User>PermissionSetAssignment>PermissionSet).

    Any help would be greatly appreciated.

    ReplyDelete