JavaScript UI Libraries & Blazor Components Suite – Smart UI Forums Data Grid CellsFormat number to x decimal places

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #102264
    xyzzy
    Member
    Up
    0
    Down

    Looking to apply a format on a cell: number to 4 decimal places.
    So given 1.2345678 display 1.2346
    The demo shows percentages, scientific, currency and exponential but not how to display a number to x decimal places.

    #102265
    xyzzy
    Member
    Up
    0
    Down

    Ok, after trying d2, n2, x2, x.xxxx the format is “0.0000”
    You really need to spend sometime on the documentation as
    “Sets or gets the column’s cells format.”
    Needs replacing with a list of the string format options.

    #102267
    admin
    Keymaster
    Up
    0
    Down

    Hi xyzzy,
    You can use the following:
    Number format strings:
    ‘d’ – decimal numbers.
    ‘f’ – floating-point numbers.
    ‘n’ – integer numbers.
    ‘c’ – currency numbers.
    ‘p’ – percentage numbers.
    For adding decimal places to the numbers, add a number after the formatting stri
    For example: ‘c3’ displays a number in this format $25.256
    Built-in Date formats:
    // short date pattern
    ‘d’ – ‘M/d/yyyy’,
    // long date pattern
    ‘D’ – ‘dddd, MMMM dd, yyyy’,
    // short time pattern
    ‘t’ – ‘h:mm tt’,
    // long time pattern
    ‘T’ – ‘h:mm:ss tt’,
    // long date, short time pattern
    ‘f’ – ‘dddd, MMMM dd, yyyy h:mm tt’,
    // long date, long time pattern
    ‘F’ – ‘dddd, MMMM dd, yyyy h:mm:ss tt’,
    // month/day pattern
    ‘M’ – ‘MMMM dd’,
    // month/year pattern
    ‘Y’ – ‘yyyy MMMM’,
    // S is a sortable format that does not vary by culture
    ‘S’ – ‘yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss’
    Date format strings:
    ‘d’-the day of the month;
    ‘dd’-the day of the month
    ‘ddd’-the abbreviated name of the day of the week
    ‘dddd’- the full name of the day of the week
    ‘h’-the hour, using a 12-hour clock from 1 to 12
    ‘hh’-the hour, using a 12-hour clock from 01 to 12
    ‘H’-the hour, using a 24-hour clock from 0 to 23
    ‘HH’- the hour, using a 24-hour clock from 00 to 23
    ‘m’-the minute, from 0 through 59
    ‘mm’-the minutes,from 00 though59
    ‘M’- the month, from 1 through 12
    ‘MM’- the month, from 01 through 12
    ‘MMM’-the abbreviated name of the month
    ‘MMMM’-the full name of the month
    ‘s’-the second, from 0 through 59
    ‘ss’-the second, from 00 through 59
    ‘t’- the first character of the AM/PM designator
    ‘tt’-the AM/PM designator
    ‘y’- the year, from 0 to 99
    ‘yy’- the year, from 00 to 99
    ‘yyy’-the year, with a minimum of three digits
    ‘yyyy’-the year as a four-digit number;
    ‘yyyyy’-the year as a four-digit number.
    Best regards,
    Peter Stoev
    Smart UI Team
    https://www.htmlelements.com/

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.