Uniface User Forum

 View Only
  • 1.  Formatting numbers in a DSP

    PARTNER
    Posted 02-20-2019 16:39

    I am trying to set up number (currency etc) formats in my DSP. I can set text-align to right, but setting a fixed number of decimals, and/or commas for the thousands appears to be beyond the scope of CSS and requires javascript to handle. 

    Has anyone got a solution they are willing to share as to how to display numbers in a DSP to a nice format? 



  • 2.  RE: Formatting numbers in a DSP

    Posted 02-20-2019 17:39

    Hi Iain, 

    Here is an example on how to format number on an input using jquery and regular expressions: https://jsfiddle.net/j0rxrun8/1/

    Hope it helps.



  • 3.  RE: Formatting numbers in a DSP

    PARTNER
    Posted 02-21-2019 10:34

    Hi Alejandro, 

    Looking at that one, it appears to work on keyup, which means it's for formatting on input, I'm looking to format several fields in many occurrences on display (page load), as well as when they are changed as a result of calculations (possibly also page load? Not sure which events fire when. 

    I was hoping this was a problem that had previously been solved within the community and we could share some known code to display numbers 'correctly' in a web-page. 

    Regards, 

    Iain



  • 4.  RE: Formatting numbers in a DSP

    Posted 02-20-2019 18:39

    I believe you should be able to handle this via the DIS($NLS(CURRENCY)) or DIS($NLS(NUMERIC)) -

    check the CHM file under "Display Formats for Numeric and Float Data"...

    Regards,

    Knut



  • 5.  RE: Formatting numbers in a DSP

    PARTNER
    Posted 02-21-2019 10:30

    Hi Knut, 

    DSPs don't appear to pay any attention to either the DIS syntax or the format trigger. I can do everything I want in the client server side, but not in the web page. 


    Thanks

    Iain



  • 6.  RE: Formatting numbers in a DSP

    PARTNER
    Posted 02-21-2019 17:17

    Okay, further updates, since 80% of these numbers are display only, if I change the widget type from editbox to Statictext_Updateable, the system starts to pay attention to the DIS() formats. 

    However, using the $NLS(CURRENCY) puts an unknown character in where there should be a pound sign. 

    Since it is now using the format trigger, I can 'roll my own' formatting to put a pound sign in, and have. 

    I am still left with the 20% of the fields which are editboxes, which I cannot format. I can live with this for the current web-page, but I can see this getting nasty when I want to do something more complex. 

    Regards,

    Iain