numToStr

returns formatting function

function numToStr(object config);
configobjectan object of formatting configuration options
functionthe formatting function

Example

//a single datatable column
columns:[
    { 
        id:"votes",
        format:webix.Number.numToStr({
            groupDelimiter:" ",
            groupSize:3,
            decimalDelimiter:",",
            decimalSize:2
        })
    }
]

Details

The config object can contain the following attributes:

  • decimalSize - the number of decimal digits in the float number. By default, 2;
  • groupSize - the number of digits in a group. By default, 3;
  • decimalDelimiter - a char which separates the decimal part in the float number. By default, ".";
  • groupDelimiter - a char which separates groups of digits. By default, ",".
  • decimalOptional - boolean. If true, allows you not to specify the number of decimal digits in the float number.
  • prefix - string. Adds prefix to the formatted number.
  • sufix - string. Adds suffix to the formatted number.
  • minusPosition - string. The position of a negative sign.
  • minusSign - string|array. A sign for a negative number.
const formatFunc = webix.Number.numToStr({ decimalOptional: true, decimalDelimiter:","});
 
formatFunc(10000.9990);
// ->10000,999
 
 const formatNegative = webix.Number.numToStr({
       groupDelimiter:" ",
       groupSize:3,
       decimalDelimiter:",",
       decimalSize:2,
       minusPosition:"parentheses",
       minusSign:"()", 
     })
 
(formatNegative(-540997.848))
// -> (540 997,85)

The method doesn't format number, but returns a function which can be used for formatting

See also
Back to top