Micke
October 2, 2024, 10:10am
1
Think Ive found a bug when using radzenNumeric in a datagrid. Quite often when entering a negative value in the input fields and then tab out - the value changes to positive. It seems to happen more often if entering a larger value.
Initially I thought it had to do with the formatting, but the problem occurs even without the formatting.
The problem is reproducible in the demo enviroment:
enchev
October 2, 2024, 2:50pm
2
I've updated several items however didn't get such problem:
Micke
October 3, 2024, 10:58am
3
I made a screen recording showing the bug.
Maybe its related to cultureInfo settings? We are using both swedish and norwegian and are experiencing the bug with both.
Micke
October 7, 2024, 8:21am
4
I cant reproduce the bug in Firefox, but its still an issue in Chrome. Did you see my previous post with the video showing the problem?
enchev
October 7, 2024, 8:30am
5
Yes, I saw your post however I'm afraid that I cannot reproduce the problem on my end. You can debug the problem at your end by attaching our source code to your app.
Micke
October 7, 2024, 9:12am
6
Could you try and change language in your webbrowser to swedish and try and reproduce the bug again? It seems to work when running Chrome in english but not swedish or norwegian.
The reason it worked in Firefix was becuase it was set to english.
enchev
October 7, 2024, 2:18pm
7
Here is the same with Chrome with Swedish activated as default:
Micke
October 10, 2024, 12:48pm
8
More ppl than us have this problem:
opened 04:19PM - 07 Mar 23 UTC
closed 07:13AM - 29 Nov 23 UTC
Ok second time I describe the bugg now Im know more exactly the problem
If you … have swedish locale the negative sign differ from the english, I dont know why but it do.
1. Go to https://localhost:44398/datafilter-odata

2. set sensors take random location and change Locale to "sv-SE"
3. Filter on order id -1, notice directly after you leave the fields -1 is changed to a longer -
4.gives following error from server: {"error":{"code":"","message":"The query specified in the URI is not valid. Syntax error: character '\u2212' is not valid at position 11 in 'OrderID eq \u22121'.","details":[],"innererror":{"message":"Syntax error: character '\u2212' is not valid at position 11 in 'OrderID eq \u22121'.","type":"Microsoft.OData.ODataException","stacktrace":" at Microsoft.OData.UriParser.ExpressionLexer.NextToken()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseComparison()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalAnd()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalOr()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpression()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpressionText(String expressionText)\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilterImplementation(String filter, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo)\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilter()\n at Microsoft.AspNet.OData.Query.FilterQueryOption.get_FilterClause()\n at Microsoft.AspNet.OData.Query.Validators.FilterQueryValidator.Validate(FilterQueryOption filterQueryOption, ODataValidationSettings settings)\n at Microsoft.AspNet.OData.Query.Validators.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings)\n at Microsoft.AspNet.OData.EnableQueryAttribute.ValidateQuery(HttpRequest request, ODataQueryOptions queryOptions)\n at Microsoft.AspNet.OData.EnableQueryAttribute.<>c__DisplayClass1_0.<OnActionExecuted>b__3(ODataQueryContext queryContext)\n at Microsoft.AspNet.OData.EnableQueryAttribute.ExecuteQuery(Object responseValue, IQueryable singleResultCollection, IWebApiActionDescriptor actionDescriptor, Func`2 modelFunction, IWebApiRequestMessage request, Func`2 createQueryOptionFunction)\n at Microsoft.AspNet.OData.EnableQueryAttribute.OnActionExecuted(Object responseValue, IQueryable singleResultCollection, IWebApiActionDescriptor actionDescriptor, IWebApiRequestMessage request, Func`2 modelFunction, Func`2 createQueryOptionFunction, Action`1 createResponseAction, Action`3 createErrorAction)"}}}
**Expected behavior**
desired behavior is to not change the negative sign to locale sign, like other frameworks. And always post numbers etc as invariant culture to server so OData dont fails
**Additional context**
Console.WriteLine($"sv: U+{(int)CultureInfo.GetCultureInfo("sv-SE").NumberFormat.NegativeSign.First():x4}");
Console.WriteLine($"en: U+{(int)CultureInfo.GetCultureInfo("en-US").NumberFormat.NegativeSign.First():x4}");
gives:
sv: U+2212
en: U+002d
swedish negative sign https://www.compart.com/en/unicode/U+2212
english negative sign https://www.compart.com/en/unicode/U+002D
I tried to fix it in the RadzenNumeric.Razor.cs with .Replace(CultureInfo.GetCultureInfo("sv-SE").NumberFormat.NegativeSign,"-"); but wrong char was still posted to the server. so probably a nicer solution is needed.
Workaround for swedish users in the blazor program.cs
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("sv-SE");
CultureInfo.DefaultThreadCurrentCulture.NumberFormat.NegativeSign = "-";
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.DefaultThreadCurrentCulture;
await builder.Build().RunAsync();
I think he is on to something with the different unicodes for swedish minus sign and english minus sign.
Maybe try changing the cultureInfo in Windows to swedish if changing the language in Chrome isnt enough to replicate the problem.
korchev
October 10, 2024, 12:51pm
9
Hi @Micke ,
We won't be trying random things hoping to reproduce the problem - please value our time. Either provide specific instructions or try to debug the problem at your machine.
Micke
October 10, 2024, 1:08pm
10
If you follow the link you will see that Pierresetteskog did quite an in-depth troubleshoot:
opened 04:19PM - 07 Mar 23 UTC
closed 07:13AM - 29 Nov 23 UTC
Ok second time I describe the bugg now Im know more exactly the problem
If you … have swedish locale the negative sign differ from the english, I dont know why but it do.
1. Go to https://localhost:44398/datafilter-odata

2. set sensors take random location and change Locale to "sv-SE"
3. Filter on order id -1, notice directly after you leave the fields -1 is changed to a longer -
4.gives following error from server: {"error":{"code":"","message":"The query specified in the URI is not valid. Syntax error: character '\u2212' is not valid at position 11 in 'OrderID eq \u22121'.","details":[],"innererror":{"message":"Syntax error: character '\u2212' is not valid at position 11 in 'OrderID eq \u22121'.","type":"Microsoft.OData.ODataException","stacktrace":" at Microsoft.OData.UriParser.ExpressionLexer.NextToken()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseComparison()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalAnd()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalOr()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpression()\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpressionText(String expressionText)\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilterImplementation(String filter, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo)\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseFilter()\n at Microsoft.AspNet.OData.Query.FilterQueryOption.get_FilterClause()\n at Microsoft.AspNet.OData.Query.Validators.FilterQueryValidator.Validate(FilterQueryOption filterQueryOption, ODataValidationSettings settings)\n at Microsoft.AspNet.OData.Query.Validators.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings)\n at Microsoft.AspNet.OData.EnableQueryAttribute.ValidateQuery(HttpRequest request, ODataQueryOptions queryOptions)\n at Microsoft.AspNet.OData.EnableQueryAttribute.<>c__DisplayClass1_0.<OnActionExecuted>b__3(ODataQueryContext queryContext)\n at Microsoft.AspNet.OData.EnableQueryAttribute.ExecuteQuery(Object responseValue, IQueryable singleResultCollection, IWebApiActionDescriptor actionDescriptor, Func`2 modelFunction, IWebApiRequestMessage request, Func`2 createQueryOptionFunction)\n at Microsoft.AspNet.OData.EnableQueryAttribute.OnActionExecuted(Object responseValue, IQueryable singleResultCollection, IWebApiActionDescriptor actionDescriptor, IWebApiRequestMessage request, Func`2 modelFunction, Func`2 createQueryOptionFunction, Action`1 createResponseAction, Action`3 createErrorAction)"}}}
**Expected behavior**
desired behavior is to not change the negative sign to locale sign, like other frameworks. And always post numbers etc as invariant culture to server so OData dont fails
**Additional context**
Console.WriteLine($"sv: U+{(int)CultureInfo.GetCultureInfo("sv-SE").NumberFormat.NegativeSign.First():x4}");
Console.WriteLine($"en: U+{(int)CultureInfo.GetCultureInfo("en-US").NumberFormat.NegativeSign.First():x4}");
gives:
sv: U+2212
en: U+002d
swedish negative sign https://www.compart.com/en/unicode/U+2212
english negative sign https://www.compart.com/en/unicode/U+002D
I tried to fix it in the RadzenNumeric.Razor.cs with .Replace(CultureInfo.GetCultureInfo("sv-SE").NumberFormat.NegativeSign,"-"); but wrong char was still posted to the server. so probably a nicer solution is needed.
Workaround for swedish users in the blazor program.cs
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("sv-SE");
CultureInfo.DefaultThreadCurrentCulture.NumberFormat.NegativeSign = "-";
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.DefaultThreadCurrentCulture;
await builder.Build().RunAsync();
korchev
October 10, 2024, 1:24pm
11
Yet we couldn't reproduce the problem. He also mentioned a workaround which you can try. You can always debug RadzenNumeric and see where the problem is.
Micke
October 10, 2024, 1:27pm
12
The workaround worked, but the next developer thats running a similar cultureInfo is going to run into the same issue.
korchev
October 10, 2024, 1:30pm
13
That's why we are asking for a reproduction. We can't change the OS culture to Swedish as we won't be able to do anything (we don't speak Swedish after all).
enchev
October 10, 2024, 2:25pm
14
Here is what I see when I change the Sensors/Location: