4

I have an outputText where I display value from a controller. This is what I am currently using:

<apex:outputText value="{0,number,###.0}"> 
  <apex:param value="{!IF(ISNUMBER(test__c),test__c,'')}" />
</apex:outputText>

If at all there a value in test__c, that value is displayed. For Example: if value is 12.432 then its is shown as 12.4

This works well for me. But now how can I add a suffix % to the outputText? i.e. I need the value as 12.4%

7

The % character is supported as part of the outputText format.

You can use syntax like this to achieve the formatting you want

<apex:outputText value="{0, number, ###.0%}">
    <apex:param value=".....your value here...."/>
</apex:outputText>
| improve this answer | |
0

Do like this -

apex:outputText value="{0,number,###.0}">
      <apex:param value="{!test_c}" />
<apex:outputText>%

suffix % at the end of <apex:outputText> tag.

| improve this answer | |
  • If i do that the value is now showing as 12.40% i.e., having two decimal places – rani Aug 7 '13 at 9:35
  • i think my problem will be solved if there is way to add % in the apex:param tag. something like test__c+%. – rani Aug 7 '13 at 9:36
  • yes i want only one digit after decimal point along with the suffix – rani Aug 7 '13 at 9:37
  • no test__c+% would give Syntax error. Are you using any javascript for calculations? – Pramod Kumar Aug 7 '13 at 9:37
  • i have no javascript running as of now. the value is directly from controller – rani Aug 7 '13 at 9:38
0

Within the curly braces the apex executions parts are located. so you just need avoid the execution section in simply within the quote but out side the curly brackets would do the trick for you.

<apex:outputText value="{0, number, ###.0}%">
    <apex:param value=".....your value here...."/>
</apex:outputText>
| improve this answer | |

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.