You need to sign in to do that
Don't have an account?

Changing styles of rows in pageBlockTable based on cell values
Hi There,
I'm sure this is much easier than I think it is.
I am using pageBlockTable to display a list of Products.
I want to be able to make the whole row grey if Product.IsActive == false.
Is there an easy way?
TIA
Hello Ben,
try this.
<apex:pageblocktable var="item" value="{!Opportunity.OpportunityLineItems}"> <apex:column style="{!IF(NOT(v.isActive__c), 'background-color:grey', '')}" value="{!v.unitPrice}"/>
</apex:pageblocktable>
All Answers
Hello Ben,
try this.
<apex:pageblocktable var="item" value="{!Opportunity.OpportunityLineItems}"> <apex:column style="{!IF(NOT(v.isActive__c), 'background-color:grey', '')}" value="{!v.unitPrice}"/>
</apex:pageblocktable>
You can use 'rowclasses' attribute in pageblocktable to customize your css and put css in Visual force page like the sample code given below:
.changecss
{
background-color:#00ff00;
}
<apex:pageblocktable rowClasses="changecss" value={!listproduct}>
Hope this helps.
This works a treat. I hadn't realised we could embed APEX in a VF page.
Thanks
when I tried this, it only made the one cell gray. this makes sense, since it applies only to the apex column. is there a way to get the entire row to turn gray?
Yes. You apply the same formatting to each column.
Yeah, that's what I ended up doing. Made me twitch to do copy/paste programming, but oh well. A limitation of the platform.
Craigmh,
One more efficient way of doing this is by using your own table and displaying data using <apex:repeat>
See below(line 3):-
Using this method is more efficient in terms of execution, but you have to define your own table and style.
It is cumbersome to write, but more efficient..
<table>
<tr ><th>Subscriber_Name</th><th>Customer Name</th></tr>
<apex:repeat value="{!Opportunity.Subscribers__r}" var="subs2">
<tr class={!IF(subs2.Name!=someVar,'red','green')}>
<td><apex:outputText value="{!subs2.Name}"/></td>
<td><apex:outputText value="{!subs2.Contact__r.FirstName}"/> <apex:outputText value=" {!subs2.Contact__r.LastName}"/></td>
</tr>
</apex:repeat>
</table>