Visualforce 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>
Output:
<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>
Output:
Can we make the row color to be same if the Account Name is same? Please help.
ReplyDeleteJust like grouping, same account names should be in same color.
Yes you can do the same.
DeleteWrite the logic in controller for rendered variable.
Cheers!!!!!