0

I am trying below code in my 'apex:dataTable'.

<apex:dataTable value="{! Opportunity.Contract }" var="contract" styleClass="productsTable">
                
            <apex:column >
                
                <apex:facet name="header"> <apex:outputText value="Products" styleClass="rowHeaderWithGoldBackground"/></apex:facet>
                
                <apex:outputText value="{!contract.id}"/>
                <apex:facet name="footer"></apex:facet>
            </apex:column>
</apex:dataTable>
0

Please go through with the below code also you can add the style in apex:column tag.

<apex:page standardController="Account" extensions="SetDataListPage" recordSetVar="accounts">
    <apex:form >
        <apex:pageBlock title="Viewing Accounts">
            <apex:dataTable value="{!accounts}" var="acc" width="60%" bgcolor="Cyan"  border="5%">
                <apex:column value="{!acc.Name}" headervalue="Name" />
                <apex:column value="{!acc.Phone}" Headervalue="Phone" />
                <apex:commandButton value="Next" action="{!Next}"/>
            </apex:dataTable>
                <apex:commandLink action="{!previous}">Previous</apex:commandLink>
                <apex:commandLink action="{!next}">Next</apex:commandLink>
        </apex:pageBlock>
    </apex:form>
</apex:page>

enter image description here

1
  • Thanks @Akshay Dhiman for sharing your solution, But this do not helped me in my case. As I want to change the background color of the column header not the entire column. I found a solution for that after reading the documentation for 'apex:dataTable', available at developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/…. I am going to share it in the thread. – Tanveer Ahmad Jan 26 at 7:02
0

I found in 'apex:dataTable' documentation available at https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_dataTable.htm that we can set the column header background color using the headerClass attribute of the dataTable. In my scenario I wrote a css class and referred it in the headerClass attribute. Below is my solution code.

<apex:dataTable value="{! Opportunity.Contract }" var="contract" styleClass="productsTable" headerClass="rowHeaderWithGoldBackground">
                
            <apex:column >
                
                <apex:facet name="header"> <apex:outputText value="Products"/></apex:facet>
                
                <apex:outputText value="{!contract.id}"/>
                <apex:facet name="footer"></apex:facet>
            </apex:column>
</apex:dataTable>

Thanks, I hope this will help the community!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.