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 

How to format currency in a dataTable

I have a data table that returns a double in one of the columns that represents currency but I am having a difficult time getting this to display correclty in a dataTable.

Essentially I want to go from this:

to this:


Thanks,
Jason
Best Answer chosen by Admin (Salesforce Developers) 
TehNrdTehNrd
I ended up just using the amount field on opportunity as a container after reading this thread:
 http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=897
but I am still struggling to get the data and the facet header to align right.

Code:
This does nothing:
<apex:column>
                <apex:facet name="header"><b>Sales Price</b></apex:facet>
                <apex:outputField value="{!lines.salesPrice.amount}" style="text-align:right"/>
</apex:column>

And this, aligns the table data to the right but not the facet header
<apex:column>
               <apex:facet name="header"><b>Sales Price</b></apex:facet>
               <apex:outputField value="{!lines.salesPrice.amount}" style="text-align:right"/>
</apex:column>

 EDIT:
I've figured it out:
 <apex:column style="text-align:right" headerClass="CurrencyElement">
                                        <apex:facet name="header"><b>Total Price</b></apex:facet>
                                        <apex:outputField value="{!lines.TotalPrice.amount}"/>
</apex:column>



Message Edited by TehNrd on 05-05-2008 02:14 PM

All Answers

TehNrdTehNrd
I ended up just using the amount field on opportunity as a container after reading this thread:
 http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=897
but I am still struggling to get the data and the facet header to align right.

Code:
This does nothing:
<apex:column>
                <apex:facet name="header"><b>Sales Price</b></apex:facet>
                <apex:outputField value="{!lines.salesPrice.amount}" style="text-align:right"/>
</apex:column>

And this, aligns the table data to the right but not the facet header
<apex:column>
               <apex:facet name="header"><b>Sales Price</b></apex:facet>
               <apex:outputField value="{!lines.salesPrice.amount}" style="text-align:right"/>
</apex:column>

 EDIT:
I've figured it out:
 <apex:column style="text-align:right" headerClass="CurrencyElement">
                                        <apex:facet name="header"><b>Total Price</b></apex:facet>
                                        <apex:outputField value="{!lines.TotalPrice.amount}"/>
</apex:column>



Message Edited by TehNrd on 05-05-2008 02:14 PM
This was selected as the best answer
David SchachDavid Schach

Sure, I'm very very late, but was searching for this myself and found a good way to do it:

 

<apex:column styleClass="numericalColumn">
  <apex:facet name="header">
    <apex:outputtext value="Amount" />
  </apex:facet>
  <apex:outputText value="{0,number,$#,###,###.00}">
    <apex:param value="{!c.Amount}" />
  </apex:outputText>
</apex:column>

Hope it helps.