Currencies or Symbols best practices

Hi all!

What are the best practices dealing with currencies or generic symbols as prefix or suffix in grid and fields?

Is there some way to manage this in a centralized way?

What about @CurrencyValue annotation?

Thanks in advance!

Hi,

@CurrencyValue works together with CurrencyField UI component (CurrencyField :: Jmix Documentation).

But it exists in Jmix 1.x only.
In case of Jmix 2.x use prefix/suffix - Prefix & Suffix :: Jmix Documentation.

Regards,
Ivan

Hi
Can this be dynamic? For example, the default currency code defined in company entity will be displayed as prefix of the amount filed based on the company selected, possible?

Hi.

Yes, you can change the text displayed as currency on the CurrencyField dynamically via CurrencyField#setCurrency.
Prefix/Suffix also can be dynamically filled with content you need.

Regards,
Ivan

I see the following in documentation, where lbs is displayed but looks like it’s static text, this can be replaced by a property field?

<textField placeholder="Enter amount">
    <suffix>
        <span text="lbs"/>
    </suffix>
</textField>

Can you please share a code snippets?

@mortoza_khan
Hello Mortoza

You can find a setSuffixComponent() code example here in the Tooltip demo.

Best regards
Chris