In our application we store big amount of decimal data. Conform to Oracle JET documentation there is possibility to format decimal numbers according provided pattern for individual input text controls.
But is there method to set default decimal pattern for all controls in application? Have any of you solved a similar dilemma?
I do not believe this is possible. The default value for the
converter
property of<oj-input-number>
, according to the documentation, isnew NumberConverter.IntlNumberConverter()
. There is no way to override this default value for all component instances.However, one thing you can do in order to reduce the number of
Converter
instances in your code, is to create yourConverter
instance in a separate JavaScript module, export it and then import the binding in the viewModels you wish to reference it from.Assuming you use a default structure and Typescript, under
src/ts
, create something likemyConverter.ts
. The content will be an exportedConverter
instance:Then, in your viewModel files, you would do something like:
And then in your HTML, you can bind
converter
to your input'sconverter
property like so:This is of course not a default value for all input component instances, you still have to manually bind the converter instance in each case, but at least you only need to maintain it at one place and it only exists in memory once.