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
RustyboyRustyboy 

Apply same style class to all columns in a PageBlockTable

Hi,

I want to shade all columns in certain rows on a PageBlockTable based on the value of one of the fields in the table. Currently I have achieved this by adding the same StyleClass to each column (see below) which seems really clunky.

Is there a way to apply the StyleClass once for the entire row.

<apex:pageBlockTable value="{!attendees}" var="att" >
                        
                        <apex:column headerValue="First Name" styleClass="{!att.Status__c}">
                            <apex:outputField value="{!att.First_Name__c}"/>
                        </apex:column>
                       
                        <apex:column headerValue="Last Name" styleClass="{!att.Status__c}">
                            <apex:outputField value="{!att.Last_Name__c}"/>
                        </apex:column>
                       
                        <apex:column headerValue="Known As Name" styleClass="{!att.Status__c}">
                            <apex:outputField value="{!att.Known_As__c}"/>
                        </apex:column>
                       
                        <apex:column headerValue="Represents" styleClass="{!att.Status__c}">
                            <apex:outputField value="{!att.Represents__c}"/>
                        </apex:column>
                       
                        <apex:column headerValue="Role" styleClass="{!att.Status__c}">
                            <apex:outputField value="{!att.Role__c}"/>
                        </apex:column>
                       
                        <apex:column headerValue="Status" styleClass="{!att.Status__c}">
                            <apex:outputField value="{!att.Status__c}"/>
                        </apex:column>

</apex:pageBlockTable>



Thanks


praveen murugesanpraveen murugesan
Hi Rusty,

I think you can apply styleclass for Pageblocktable itself.

Thanks.
Matt WhalleyMatt Whalley
you can apply a class to the styleClass attribute, check https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageBlockTable.htm for more details.
RustyboyRustyboy
I tried putting the StyleClass on the PageBlockTable before posting my question. The problem is that the style is dependent on a value in the table itself, see bold below

<apex:pageBlockTable value="{!attendees}" var="att" >
                       
                        <apex:column headerValue="First Name" styleClass="{!att.Status__c}">
                            <apex:outputField value="{!att.First_Name__c}"/>
                        </apex:column>


When I tried to move the StyleClass into the PageBockTable I received an error saying variable att.Status__c not known.

Is there a way I can wrap something around all the columns after the PageBlockTable? eg:

<apex:pageBlockTable value="{!attendees}" var="att" >
   <apex:another Tag styleClass="{!att.Status__c}">
       <apex column etc....

I thought of <apex:outputPanel> might work but didn't feel right

Thanks

Matt WhalleyMatt Whalley
then what you have should work.  Have you used the variable att somewhere else?  I've seen it mess up when you use the same variables at times.
RustyboyRustyboy
Thanks Matt.

Apologies, it may not have been clear in the original question. What I have DOES work, but it just seems a really inelegant way of solving the problem