[SalesForce] how to remove salesforce hover highlight on pageblock table.

I am changing the pageblocktable cell colors dynamically based on value but due to salesforce standard style on pageblocktable removing my color.

please suggest.

it is changing on mousover

enter image description here

Best Answer

This really depends on your Visualforce code and what you're checking against. For each column you can use a formula to determine whether or not a class gets used. For example:

<style>
  .green {
    background: green;
  }
</style>

<apex:pageBlock>
  <apex:pageBlockTable value="{!myTable}" var="t">
    <apex:column styleClass={!IF(t.DateField__c > TODAY()), 'green', '')}     value="{!t.DateField__c}" />
  </apex:pageBlockTable>
</apex:pageBlock>

You've not specified much, but the trick is here:

{!IF(t.DateField__c > TODAY), 'green', '')}

In other words for this example, if DateField__c is greater than today, return green. green is a CSS class and the formula is within the styleClass parameter. So, if the date is indeed greater than today, it'll render something like this:

<apex:column styleClass="green" [...]

Edit

To answer your second question, in your CSS you'd need something like this:

.green:hover {
    colour: darkgreen;
}

Salesforce will have some standard styling and :hover will be one of them. You'll want to override/cascade over that by using your own class.

Alternatively, you could do:

.green {
  background: green !important;
}

Although I'd avoid using this personally.