How to send decimal number from numeric textbox to contoller without losing point ?

Hi, 

I have a numberic textbox  as following but when i post form point is lost even though model property is decimal. For example i'm entering 55.65. When i post i see 5565M in model data. How can i fix it ?


<ejs-numerictextbox id="clientDiscountAmount" ejs-for="ClientPackage.DiscountAmount" format="#.## TL" placeholder="İndirim Tutarı" cssClass="e-outline" min="0" floatLabelType="Auto"></ejs-numerictextbox>

Thanks



12 Replies

SN Sevvandhi Nagulan Syncfusion Team June 1, 2020 11:27 AM UTC

Hi Tümer, 


Greetings from Syncfusion support. 


We checked the recorded issue ("When the decimal number value is entered, the decimal separator is lost when receiving the value in the controller"). The scenario mentioned is working in the NumericTextBox component. Please refer to the screenshot below, 

 





The reported issue will occur when the culture is being used.So please confirm that you use the culture in your application. If so, share the culture that you used in the application as well, share the syncfusion nuget version used in the application. 


Regards, 
Sevvandhi N 



JS Jaime Sepulveda June 5, 2021 06:32 PM UTC

Hi, 

I've a similar issue. In my case, if you enter 11.25 my controller receive 11, when the numerictextbox is inside a Dialog.  I tried with locales, decimal places, etc. without success. Tasa field is a float by the way.

All based on https://ej2.syncfusion.com/aspnetcore/Grid/DialogTemplate#/material



SN Sevvandhi Nagulan Syncfusion Team June 7, 2021 10:45 AM UTC

Hi Jaime, 

Greetings from Syncfusion support.

We are currently checking the reported issue at our end. We will update further details on 8th of June,2021. We appreciate your patience until then. 


Regards, 
Sevvandhi N 



MS Manivel Sellamuthu Syncfusion Team June 8, 2021 10:12 AM UTC

Hi Jaime, 
 
Thanks for your patience. 
 
We have prepared a sample based on the reported issue. But we did not faced the mentioned issue, please refer the below screenshots and sample for more information. 
 
 
 
 
 
 
 
 
If you still faced the issue  , please share the below details 
 
  1. Share the complete Grid code (code for ej_selectAll also)
  2. Have you modified the Grid value for number field before sending to the server using actionBegin event or some other event, please share the details if any
  3. If possible, please try to replicate the issue in the given sample
 
Regards, 
Manivel 



JS Jaime Sepulveda July 6, 2021 05:10 PM UTC

Hi,

Sorry I don't see this before...


Your example works fine. I noticed you use Double for numbers fields, so I create a second field with the name Tasa2 and execute my program.

This is the input screen:


And I receive this in my controller (same order of the previous image)


I try with and without ej_selectAll​, and the result is the same.


I believe is something relate with decimal separator. This is my config by the way

{
"main": {
"es-CL": {
"identity": {
"version": {
"_cldrVersion": "36"
},
"language": "es",
"territory": "CL"
},
"numbers": {
"defaultNumberingSystem": "latn",
"otherNumberingSystems": {
"native": "latn"
},
"minimumGroupingDigits": "2",
"symbols-numberSystem-latn": {
"decimal": ".",
"group": ",",
"list": ";",
"percentSign": "%",
"plusSign": "+",
"minusSign": "-",
"exponential": "E",
"superscriptingExponent": "×",
"perMille": "‰",
"infinity": "∞",
"nan": "NaN",
"timeSeparator": ":"
},


JS Jaime Sepulveda July 6, 2021 10:44 PM UTC

UPDATE: With decimal type is the same




MS Manivel Sellamuthu Syncfusion Team July 7, 2021 11:00 AM UTC

Hi Jaime, 

Thanks for your update. 

We have applied es-CL culture in our given sample and checked the reported issue. But it is working fine at our end. Please refer the below screenshot, code example and sample for more information. 

<ejs-grid id="Grid"  . . . 
. . . 
        <e-grid-column field="Freight" headerText="Freight" textAlign="Right" format="N2" width="120"></e-grid-column> 
. . . 
    </e-grid-columns> 
</ejs-grid> 
 <div class="form-row"> 
        <div class="form-group col-md-6"> 
            <ejs-numerictextbox id="Freight" [email protected] format="N2" focus="ej_selectAll" Type="text" placeholder="Freight" floatLabelType="Always"></ejs-numerictextbox> 
        </div> 
        public IActionResult Update([FromBody]CRUDModel<Ordersvalue) 
        { 
            var data = order.Where(or => or.OrderID == value.Value.OrderID).FirstOrDefault(); 
            if(data != null) 
            { 
                data.OrderID = value.Value.OrderID; 
                data.CustomerID = value.Value.CustomerID; 
                data.EmployeeID = value.Value.EmployeeID; 
                data.OrderDate = value.Value.OrderDate; 
                data.ShipCity = value.Value.ShipCity; 
                data.Freight = value.Value.Freight; 
                data.Verified = value.Value.Verified; 
            } 
            return Json(value.Value); 
        } 

Screenshot: 

Here we are changing the existing value (98.55) to 20.55. 

 

Now you can see that while sending the data to server the (20,55) culture formatted value changed to (20.55) standard value. 

 

In server we are able to access the data as sent from the client 

 


If you still faced the issue, please share the below details 

  1. Please ensure that you are using the latest version Syncfusion scripts
  2. Please try to replicate the reported issue in the given sample
  3. If possible, please share the issue replicable sample

Regards, 
Manivel 



JS Jaime Sepulveda July 9, 2021 01:07 AM UTC

Hi,

It's not working... but I believe this is related to this

Because Chrome is sending comas as decimal separator although I set decimal separator as point.


Any idea how to setup the proper decimal separator at the server side?




JS Jaime Sepulveda July 9, 2021 06:08 AM UTC

This is what I need to change 



The comma for a point.



MS Manivel Sellamuthu Syncfusion Team July 9, 2021 06:55 AM UTC

Hi Jaime, 

Thanks for your update. 

We are glad that you have found the solution on your own. 

Please let us know if you need further assistance. 

Regards, 
Manivel 



JS Jaime Sepulveda July 9, 2021 09:45 PM UTC

Hi, 


Sorry but I don't found the solution, just the cause of the problem as explain before.

My app requires to manage date in dd-MM-yyyy and decimals with points. If I use es-CL culture I solve the date part, but not the number; in other hands, if I set en-US I solve the numbers but not the dates... any idea how to mix two cultures?


Jaime



MS Manivel Sellamuthu Syncfusion Team July 13, 2021 01:45 PM UTC

Hi Jaime, 

Thanks for your update. 

Based on your requirement you want to receive the dates in dd-MM-yyyy format and number values in  ##.## in both en-US and es-CL cultures. 

In our given sample it is working as expected. Please refer the below screenshots and sample for more information. 

While using es-CL culture 

 

While using en-US culture 

 


You can check this in the above sample and  by default the sample will be in es-CL culture and you can comment the below highlighted code to check the en-US culture.  

[Index.cshtml] 

<script> 
    document.addEventListener('DOMContentLoaded', function () { 
        var L10n = ej.base.L10n; 
        loadCultureFiles('es-CL'); 
        ej.base.setCulture('es-CL'); 
    }); 

To proceed further please check the above sample and confirm us this is your exact requirement or not. If we misunderstood your query or this is not your exact requirement,  
please explain more about your requirement. 

Regards, 
Manivel 


Loader.
Up arrow icon