The formatting can be applied against columns of ron and edn types (the formating is defined for each column separately, so you can have different formatting types for different columns).
The basic syntax is:
grid.setNumberFormat(mask,index)
Or in case of initialization from XML:
<column format="mask"...
Or when initialization is from HTML:
<td ... format="mask"...
The mask defines how the number will be formatted, basically it is the string of zeros with two separators:
. - defines where the decimal point will be placed;
, - defines where the group separator will be placed.
data => mask => result 123456.789 => 0.00 => 123456.78 123456.789 => 0,000.00 => 123,456.78 123456.789 => 00,00 => 12,34,56
The 3rd and 4th parameters can be used to define the group separator and the decimal separator characters.
mygrid.setNumberFormat("0,000.00",index,".",","); //(US English) 1456.789 => 1,456.78 mygrid.setNumberFormat("0,000.00",index,",",""); //(English) 1456.789 => 1456.78 mygrid.setNumberFormat("0,000.00",index,","," "); //(French) 1456.789 => 1 456.78 mygrid.setNumberFormat("0,000.00",index,",","."); //(Russian) 1456.789 => 1.456,78 mygrid.setNumberFormat("0,000.00",index,"."," "); //(Greek) 1456.789 => 1 456.78 mygrid.setNumberFormat("0,000.00",index,".","'"); //(Swiss) 1456.789 => 1'456.78
If you want the chars to be used as decimals, groups separators can be set globally as part of grid internationalization.
grid.i18n.decimal_separator="," grid.i18n.group_separator="."; mygrid.setNumberFormat("0,000.00",index); 1456.789 => 1.456,78
FYI: If you have a statistics counter assigned to the column with defined numeric format, the formatting will be applied to results of the calculation as well.
(This will work even if the column type is different from ron|edn - so you can have a column with custom cell types and still have formatting applied to statistics counters)