1

I am currently using the visual force component to get the grand total of my pageblocktable column as referred too in this question 'To achieve Grand total for the retrieved column in a datatable generated using Soql' Please and help will be greatly appreciated. Thanks! Here is the total. How can I format this in to dollar amount? Nothing is working, please advise.

3
  • Jonathan, what precisely isn't working ? Maybe we can better understand if you show us your code and current progress or attempts. – Samuel De Rycke Jan 29 '15 at 15:52
  • Is this better? – Jonathan Brooks Jan 29 '15 at 21:21
  • This is the code it is all visual force. – Jonathan Brooks Jan 30 '15 at 14:23
1

Below is the code which could help you in formatting total value : <script> function numberWithCommas(x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } // Here we will set the generated subtotals to the footer cells document.getElementsByClassName('t4')[0].innerHTML = '$ '+numberWithCommas({!total4}); </script>

This will allow you to maintain comma in between total value. Example Total: 397423.66 will be displayed as 'Total: $ 397,423.66'

1
  • hot diggidy daym! Thats some sweet code right there! All those escapes n stuff. Impressive! – kazoolsky Aug 19 '15 at 6:37
0

Pretty sure you need to add an apex:param between the apex:outputText tags that contains the value you wish to format.

<apex:outputText value"{0,number,$###,###,##0.00}">
    Total
    <apex:param value="{!total4}" />
</apex:outputText>
1
  • I tried this and it did not work because total4 is an apex variable but I got it figured out the Javascript just will not show when it is in being rendered as a PDF now. – Jonathan Brooks Jan 30 '15 at 14:24
0

If you are setting the GrandTotal using Javascript, why not add the $ during that point?

document.getElementsByClassName('t4')[0].innerHTML = '${!total4}';

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.