Hello Radzen team,
the source code for Numeric Input Demo is wrong:
source:
I have problems with displaying numeric in percentage format and when looking for a solution i noticed that the demo code is wrong
Thomas
Hello Radzen team,
the source code for Numeric Input Demo is wrong:
I have problems with displaying numeric in percentage format and when looking for a solution i noticed that the demo code is wrong
Thomas
Thanks @enchev!
btw... can you add an example for percentage format? a cant get it to work.
i have a decimal (5,4) column in sql server. numeric format "p" in radzen ide.
when i type "20" and leave the field numeric shows "2000,00 %". i think the numeric dont divide by 100.
but no user will type "0,2" to see "20,00 %" after leaving the field.
user want type 20 to see "20,00 %" but in the database "0.2" must be stored.
perhaps the numeric itsself can divide by 100. maybe a new property "As Percentage" or "Fractional" something like that can do that?
will you implement this?
Thomas
Use a myPercentage = args.ToPercentage()
in the change event of the numerical
and define a method like this that wil do type conversion of the users input 68% becomes 0.68
with Format="0.## %"
it wil still display 68%
public static double ToPercentage(this double? target)
{
return ToPercentage(target.GetValueOrDefault());
}
public static double ToPercentage(this double target)
{
return target switch
{
< 1 => target,
_ => target / 100
};
}