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
TehNrdTehNrd 

Can't overide the style for a outputField.

I have an output field in a pageBlock section and I am trying to make the value red. The field is Amount on opportunity but I am using it as a proxy variable to hold a currency total. Any idea why my styles aren't working?

Code:
<apex:pageBlockSectionItem >
<apex:outputLabel value="Total NSP Amount" for="nsptotal"/>
<apex:outputField value="{!masterDiscount.Amount}" id="nsptotal" style="color: red; font-weight: bold"/>
<apex:pageBlockSectionItem >

Thanks,
Jason

TehNrdTehNrd
This seems to work.

Code:
<apex:pageBlockSectionItem >
<apex:outputLabel value="Total NSP Amount" for="nsptotal"/>
<apex:outputPanel>
   <span style="color:red; font-weight: bold">
       <apex:outputField value="{!masterDiscount.Amount}" id="nsptotal"/>
   </span>
</apex:outputPanel>
</apex:pageBlockSectionItem>

I think I remember Jill mentioning this may be a bug and this is the correct workaround.

Karan BhadiadraKaran Bhadiadra

Thankyou TehNrd.

namithanamitha
Code:
<apex:pageBlockSectionItem > <apex:outputLabel value="Total NSP Amount" for="nsptotal"/> <apex:outputPanel> <span style="background-color:#d0f5a9"> <apex:outputField value="{!masterDiscount.Amount}" id="nsptotal" style="background-color:#d0f5a9">
<apex:inlineEditSupport event="ondblclick"/>
</apex:outputField> </span> </apex:outputPanel> </apex:pageBlockSectionItem>

When i enable inline edit support background color is not displayed.Please provide a solution for this.



crop1645crop1645
namitha - styling outputField components within inlineEdit requires delving into the DOM (e.g. Firebug for Mozilla Firefox) and then using jQuery to add CSS to the desired field. In your example, the following would work (assuming I don't enter any typos and assuming you know how to use jQuery on a VF page - see developer.force.com doc here (http://developer.force.com/cookbook/recipe/using-jquery-in-a-visualforce-page)):

<pre>
$j('span[id$="nsptotal_ileinner"]').css({'background-color'  : '#d0f5a9'});
</pre>
richardc020richardc020
Why doesn't the outputField documentation reflect that no attributes ever work except value? That's the result of my testing.