Custom numeric Datatype and per-field formats

Hi,
I’ve created a custom datatype (PercentageDatatype) in order to manage a percentage (value range 0-100, saved in database as a double and visually rendered as a number followed by % symbol).
I’ve create the class extending NumberDatatype implementing Datatype, mostly inspired by similar class like DoubleDatatype, adding on top of it the annotation NumberFormat specifying a format string.
so far so good: it works as expected, but now I would like to have the ability to annotate with NumberFormat the field of the Entity thwt will uses it, making componets pick it up as with DoubleDatatype (I’ve tryed but Studio erase it every time I use design, but anyway it does not work)
Is it possible?

thank you

Hi Michelle,

Unfortunately it’s impossible: Jmix uses a special AdaptiveNumberDatatype class when it encounters the NumberFormat annotation on entity attribute.

So the format must be specified on your datatype, and the attribute must have no own NumberFormat for your datatype to be used.

Ok, thank you Konstantin