Menu
Download Free Trial
Table of contents

setFormat

setFormat(format:Format Object, measureName:String)

[starting from version: 1.4]

Sets a default number format or the number format for the specified measure.

You can apply a format to all measures if you leave measureName parameter undefined. Or you can apply a format only to a specific measure if you specify measureName parameter.

Use refresh() API call after setting a format to redraw the component and see changes.

Parameters

  • Format Object – the object that contains the number format parameters.
  • measureName (optional) – the unique name of the measure. Specify measure’s unique name to apply a format to it or leave it undefined if you want to override a default format. Please note that if you want to override a default format, name property in format object should be an empty string – "".

Examples

1) How to override a default number format in run time:

var format = {
  name: "",
  decimalPlaces: 0,
  thousandsSeparator: ","
};
flexmonster.setFormat(format);
flexmonster.refresh();

Try how the sample works on JSFiddle.

2) How to change a currency symbol:

var format = flexmonster.getFormat("Price");
format.currencySymbol = "$";
//format.currencySymbol = "£" // pound sterling
//format.currencySymbol = "€" // euro
//format.currencySymbol = "¥" // yen
flexmonster.setFormat(format, "Price");
flexmonster.refresh();

Open the example on JSFiddle.

See also

getFormat
Format Object
refresh