Hi Grant,
Thanks for the attachment. We have check with the attachment and here is the detailed explanation about setCurrencyCode method,
The setCurrencyCode method can be used only for setting/ changing the global currency for all EJ2 components in the application. Please find the behavior of the setCurrencyCode in our components in below:
1.Used ‘setCurrencyCode’ before component rendered.
If the setCurrencyCode method is called before the component render then the global currency(ex: EUR) code will be set for components that doesn’t have set the currency property set.
// set currency code before component render.
setCurrenyCode(‘EUR’);
// currency code not set component wise.
let textbox1 = new NumericTextBox({
value: 2345.67,
format: 'c2',
}, this.el.querySelector('#noCurrency') as HTMLInputElement);
/// default currency code set.
let textbox2 = new NumericTextBox({
value: 2345.67,
format: 'c2',
currency: 'AUD',
}, this.el.querySelector('#audCurrency') as HTMLInputElement); |
In the above code example, when we set currency code ‘EUR’ before component render the two instances will have different currency values. In the ‘textbox1’ the value will be displayed in the ‘EUR’ and for the ‘textbox2’ value will be displayed in ‘AUD’.
2. Used ‘setCurrencyCode’ after component rendered.
If the setCurrencyCode method is called after the component render then the global currency(ex: EUR) code will be changed to all the components in the page.
// currency code not set component wise.
let textbox1 = new NumericTextBox({
value: 2345.67,
format: 'c2',
}, this.el.querySelector('#noCurrency') as HTMLInputElement);
/// default currency code set.
let textbox2 = new NumericTextBox({
value: 2345.67,
format: 'c2',
currency: 'AUD',
}, this.el.querySelector('#audCurrency') as HTMLInputElement);
// set currency code after component render.
setCurrenyCode(‘EUR’); |
In the above code example when we set currency code ‘EUR’ sets after the component render the two instances ‘textbox1’ and `textbox2` will have same currency values `EUR`. Above mentioned are the behavior of the setCurrencyCode method and if we need to maintain separate currency codes for each component, do not use the setCurrencyCode after component rendered.
Please let us know if you have any concerns.
Thanks,
Christo