You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
853 B
18 lines
853 B
8 months ago
|
import {FieldOptions} from 'app/client/widgets/NewBaseEditor';
|
||
|
import {NTextEditor} from 'app/client/widgets/NTextEditor';
|
||
|
|
||
|
export class NumericEditor extends NTextEditor {
|
||
|
constructor(protected options: FieldOptions) {
|
||
|
if (!options.editValue && typeof options.cellValue === 'number') {
|
||
|
// If opening a number for editing, we render it using the basic string representation (e.g.
|
||
|
// no currency symbols or groupings), but it's important to use the right locale so that the
|
||
|
// number can be parsed back (e.g. correct decimal separator).
|
||
|
const locale = options.field.documentSettings.peek().locale;
|
||
|
const fmt = new Intl.NumberFormat(locale, {useGrouping: false, maximumFractionDigits: 20});
|
||
|
const editValue = fmt.format(options.cellValue);
|
||
|
options = {...options, editValue};
|
||
|
}
|
||
|
super(options);
|
||
|
}
|
||
|
}
|