How do format output text to show only whole numbers and not decimals along with it in Vf page
Asked Answered
A

1

5

I want to display a field in a object to show just the whole number/integer value. This field has decimal values in the structure but for i need to show the integer value for this VF page only.

 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="# Connections" for="Connections"/>
                    <apex:outputText id="Connections" value="{!Event__c.Total_Connections__c}" />         
                </apex:pageBlockSectionItem>

No of connections has to be shown as whole number.

thanks

Afore answered 11/2, 2012 at 7:36 Comment(0)
A
8

You can use parametrized output with formating, for example:

<apex:outputText id="Connections" value="{0, number, integer}">
    <apex:param value="{!Event__c.Total_Connections__c}" />
</apex:outputText>

For more detail about all the formating options, check Java's MessageFormat, the same formating is used for <apex:outputText>

Abydos answered 11/2, 2012 at 10:17 Comment(2)
You can also cheat for this particular case, and just do `value="{!FLOOR(MyVar)}"' — nice and easy way of getting rid of that pesky decimal!Heeled
any idea how to get this to work in site.com? When I do an output in a Data Element, I'm always getting the decimal value. I was hoping to use this, "{!FLOOR(MyVar)}", but site.com doesn't recognize the FLOOR function.Kaleidoscopic

© 2022 - 2024 — McMap. All rights reserved.