Hi.
Problem looks similar to this one
Here's the way I used this component
<RadzenNumeric TValue="double" Step="0,5" Placeholder="Enter weight in kilograms" @bind-Value="@ProductVariant.Weight" Style="margin-bottom: 20px" />
Problem occurs when Numeric tries to display a number with decimal part, eg. 12.5 - field stays empty or displays placeholder (when placeholder is configured).
Everything works fine, when value to display is integral, eg. 4
Issue cannot be reproduced in online demo, because @bind-Value is not used there in combination with double datatype.
Here's what I figured out so far.
- Step attribute has to be passed using current locales number format (setting DecimalSeparator and ThousandSeparator has no effect). Otherwise the following exception is thrown :
Error: System.FormatException: Input string was not in a correct format.
at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
at System.Double.Parse(String s)
at Radzen.Blazor.RadzenNumeric1.UpdateValueWithStep(Boolean stepUp) at Radzen.Blazor.RadzenNumeric
1.b__0_0(MouseEventArgs args)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
- If Step attribute is parsed sucessfully, bound value is updated properly, but...
- When value is not integral (contains fractional part) Numeric does not display value (empty field or configured placeholder is displayed). Setting DecimalSeparator and ThousandSeparator has no effect.
- Typing value with .(dot) as well as ,(comma - my current locale) as decimal separator updates value accordingly
Could you look into this?
EDIT:
To illustrate the problem, below is behavior of RadzenInput I am experiencing:
I have placed RadzenInput next to input (asp.net core component). Both controls are bound to the same variable.
Please note that RadzenInput needs ,(comma) as Step
value, whereas step
of input
requires .(dot)
<RadzenNumeric TValue="decimal" Step="0,5" Placeholder="Enter weight in kilograms" @bind-Value="@ProductVariant.Weight" />
<input type="number" step="0.5" placeholder="Enter weight in kilograms" @bind-value="@ProductVariant.Weight"/>
Now - the displaying problem... Initial state looks like below:
When value is changed with arrow buttons (using input
) - the new state looks like below:
Change once again...