-
-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NumericEdit Decimal not dynamically handled #1703
Comments
That is right, first render is ok (with 2 decimals). |
Ah, so you want to change the decimals dynamically? Well, I can probably make it work, somehow, but I don't see why would you do it. For example, if you make smaller decimals you would lose data, so for example if you have |
I tried to make it work by using an <Addons>
<Addon AddonType="AddonType.Body">
@if ( unit == "kelvin" )
{
<NumericEdit TValue="decimal" Value="@temperature" Decimals="1" />
}
else if ( unit == "celsius" )
{
<NumericEdit TValue="decimal" Value="@temperature" Decimals="2" />
}
</Addon>
<Addon AddonType="AddonType.End">
<Dropdown>
<DropdownToggle Color="Color.Primary">@unit</DropdownToggle>
<DropdownMenu>
<DropdownItem Clicked="@(()=>unit="kelvin")">kelvin</DropdownItem>
<DropdownItem Clicked="@(()=>unit="celsius")">celsius</DropdownItem>
</DropdownMenu>
</Dropdown>
</Addon>
</Addons>
@code{
decimal temperature = 12.34m;
string unit = "kelvin";
} I expected to at least initialize input with decimal places, but no luck. It seems this is a known problem https://stackoverflow.com/questions/22641074/html5-number-input-always-show-2-decimal-places Going on list as a bug. |
The https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode __builder.AddAttribute(2, "inputmode", "numeric"); <input id="0HM75QGA95EV1" inputmode="numeric" class="form-control" placeholder="Amount" _bl_18f8e820-d16c-4e1c-ba8f-1ca63b21fa3d=""> |
|
@stsrki Because of |
I must admit you're right. I never even noticed that |
I have another use case. When inputting a price/cost field, where you can have several currencies, you need not only to change the decimal numbers for each currency, also the culture, as it's not the same £3.00 than 3,00€, but if you pass es-es with GBP it will print 3,00£ that's incorrect, and with en-gb it will print €3.00 that's incorrect as well. I think it's a pretty solid reason to be able to dynamically bind not only the decimal points but also the culture. |
<Addons>
<Addon AddonType="AddonType.Body">
<NumericEdit TValue="decimal" @bind-Value="@temperature" Decimals="@(unit=="kelvin"?1:2)" />
</Addon>
<Addon AddonType="AddonType.End">
<Dropdown>
<DropdownToggle Color="Color.Primary">@unit</DropdownToggle>
<DropdownMenu>
<DropdownItem Clicked="@(()=>unit="kelvin")">kelvin</DropdownItem>
<DropdownItem Clicked="@(()=>unit="celsius")">celsius</DropdownItem>
</DropdownMenu>
</Dropdown>
</Addon>
</Addons>
@code{
decimal temperature = 12.34m;
string unit = "kelvin";
} |
Hello,
I'm working on a page with the NumericEdit component and Decimals property doesn't work like I think it should:
Note the same issue for Min and Max.
The text was updated successfully, but these errors were encountered: