Decimal point in edit dialog grid

Hi

I load the cldr-data files on each page through _Master layout, this works for the grids, in fact the decimal values contain the comma as a decimal point, as expected by the Italian culture, but when I open the grid editing dialog, the value appears with the period and not with the comma, also if I insert a number with the comma , the decimal part is not considered.

Example: 10,50 return 10.00 / 10.50 return 10.50



18 Replies

MS Manivel Sellamuthu Syncfusion Team August 2, 2021 01:46 PM UTC

Hi Pio, 
 
Greetings from Syncfusion support. 
 
We have validated your reported query. From your query we suspect that in the Grid Dialog editing the numeric text box is not considered the decimal values with ‘,’ separator even applied the Italian culture. 
But the reported scenario is not replicated at our end. Please find the below sample and code example for your reference. 
 
 
<script> 
    ej.base.L10n.load({ 
        'it': { 
            'grid': { 
                'EmptyRecord''Keine Aufzeichnungen angezeigt', 
                'GroupDropArea''Ziehen Sie einen Spaltenkopf hier, um die Gruppe ihre Spalte', 
                'UnGroup''Klicken Sie hier, um die Gruppierung aufheben', 
                'EmptyDataSourceError''DataSource darf bei der Erstauslastung nicht leer sein, da Spalten aus der dataSource im AutoGenerate Spaltenraster', 
                'Item''Artikel', 
                'Items''Artikel' 
            }, 
            'pager': { 
                'currentPageInfo''{0} von {1} Seiten', 
                'totalItemsInfo''({0} Beiträge)', 
                'firstPageTooltip''Zur ersten Seite', 
                'lastPageTooltip''Zur letzten Seite', 
                'nextPageTooltip''Zur nächsten Seite', 
                'previousPageTooltip''Zurück zur letzten Seit', 
                'nextPagerTooltip''Zum nächsten Pager', 
                'previousPagerTooltip''Zum vorherigen Pager' 
            } 
        } 
    }); 
</script> 
<div> 
    @Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.datasource).Columns(col => 
{ 
    col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).ValidationRules(new { required = "true" }).Add(); 
    col.Field("CustomerID").HeaderText("Customer Name").Width("150").ValidationRules(new { required = "true", minLength = 3 }).Add(); 
    col.Field("Freight").HeaderText("Freight").Width("120").EditType("numericedit").Format("N2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
    col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); 
    col.Field("ShipCountry").HeaderText("Ship Country").EditType("dropdownedit").Width("150").Add(); 
 
}).AllowPaging().EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render() 
</div> 
 
   <div class="container body-content"> 
        @RenderBody() 
    </div> 
    <script> 
        function loadCultureFiles(name) { 
            var files = ['numbers.json''timeZoneNames.json''currencies.json''ca-gregorian.json']; 
            var loadCulture = function (prop) { 
                var val, ajax; 
                ajax = new ej.base.Ajax(location.origin + '/../../scripts/cldr-data/main/' + name + '/' + files[prop], 'GET'true); 
                ajax.onSuccess = function (value) { 
                    val = value; 
                    ej.base.loadCldr(JSON.parse(val)); 
                }; 
                ajax.send(); 
                ej.base.setCulture('it'); 
                ej.base.setCurrencyCode('EUR') 
            }; 
            for (var prop = 0; prop < files.length; prop++) { 
                loadCulture(prop); 
            } 
        } 
        document.addEventListener('DOMContentLoaded'function () { 
            loadCultureFiles('it'); 
        }); 
    </script> 
 
    @Scripts.Render("~/bundles/jquery") 
    @Scripts.Render("~/bundles/bootstrap") 
    @RenderSection("scripts", required: false) 
 
    @Html.EJS().ScriptManager() 
</body> 
</html> 
 
 
 
 
 
 
 
 
 
If you still faced the issue, could you please share the below details, which will be helpful for us to validate further about issue. 
 
  1. Share the complete Grid code
  2. Please try to replicate the issue in the given sample
  3. Please share the issue replicable sample (if possible)
  4. Share the screenshot or video demo of the issue
 
Regards, 
Manivel 



PL Pio Luca Valvona August 3, 2021 07:31 AM UTC

Hi Manivel,

thank you for support.

Actually I tried to make an example with the suggestions you gave me, and it worked, but if the same code I insert it into my project the problem occurs.

I'm afraid the responsibility lies with the database returning a value with the comma instead for the decimal type.

I don't know where to fix the problem.



PL Pio Luca Valvona August 3, 2021 12:54 PM UTC

Hi Manivel,

I create a new sample, which I attach to you and in this case the problem occurs.


Attachment: GridUpdated861021168_75641676_44a7a8f5.zip


MS Manivel Sellamuthu Syncfusion Team August 5, 2021 01:02 PM UTC

Hi Pio, 
 
Thanks for your update. 
 
We have checked “Decimal point in grid edit dialog is not working” in the provided sample. While checking the sample we found that using Textbox for the decimal column(Value) is the cause of your reported problem. The textbox column returns the decimal value as string. The decimal points are excluded in the server while deserializing string value. 
 
So to resolve the issue we suggest you to use the EJ 2 NumericTextbox for the Value column, which returns the value as number. We have modified the provided sample based on that. Please refer the below code example and sample for more information. 
 
[_UP.cshtml]  
. . . 
<div class="e-float-input e-control-wrapper"> 
// here we have rendered the numerictextbox for the Value column while editing 
    @Html.EJS().NumericTextBox("Value").Value(Model.Value).Format("C2").Placeholder("Value").FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Always).Render() 
</div> 
. . . 
@Html.EJS().ScriptManager() 
[_PP.cshtml]  
 . . . 
<div> 
// here we have rendered the numerictextbox for the Value column while adding 
    @Html.EJS().NumericTextBox("Value").Format("C2").Placeholder("Value").Render() 
</div> 
. . . 
 
 
 
Please let us know if you need further assistance. 
 
Regards, 
Manivel 



PL Pio Luca Valvona August 6, 2021 10:15 PM UTC

Hi Manivel,

unfortunately the proposed solution does not work, as you can see from the images

screen1.png

Screen2.jpeg

Screen3.jpeg

screen4.png

screen5.jpg





MS Manivel Sellamuthu Syncfusion Team August 9, 2021 03:36 PM UTC

Hi Pio, 

Thanks for your update. 

In our previous update we have provided the working sample and video demonstration of that. Could you please ensure that which is working fine at your end or not. Also from the shared screenshots we suspect that you have different code from the previous shared sample.  To find out the exact cause in your current sample, please share the below details 

  1. Share the network tab screenshot. For example
 
 
         
  1. In the actionBegin event while the requestType is “save” log the value in console and share the screenshot
 
  function onActionBegin(args) { 
            if (args.requestType === "save") { 
                var listInstance = args.form.querySelector("#CountyId").ej2_instances[0]; 
                args.data["CountyId"] = listInstance.value; 
                console.log(args.data); 
           } 
         
 
 
 
 
  1. Share the model class for deserializing the values in server side. Please find the model class used in your previous code example
 
                

Regards, 
Manivel 



PL Pio Luca Valvona August 9, 2021 04:13 PM UTC

Hi Manivel,

the example attached to your previous answer, works fine, but the same code inserted in my project returns a different result as you can see in the images.

 1.
    1.png

1.1.png

2.
   2.png

3.
  3.png

3.1.png


MS Manivel Sellamuthu Syncfusion Team August 10, 2021 01:20 PM UTC

Hi Pio, 

We have created a new incident under your Direct trac account to follow up with this query. We suggest you to follow up with the incident for further updates. Please log in using the below link.   


Regards, 
Manivel 



SF Sara Fernández June 13, 2023 01:24 PM UTC

I have the same problem. Could you resolve it?

Thanks



AN Antonio June 23, 2023 10:28 PM UTC

The same problem to me with Asp.Net Core, the grid display correctly the decimal numbers.

<e-grid-column field="Prezzo" headerText="Prezzo" validationRules="@(new { required=true})" format="c2" width="150" textAlign="Right"></e-grid-column>



When I start editing in dialog the decimal is always correct.

<ejs-numerictextbox ejs-for="Prezzo" format="c2" validateDecimalOnType="true" min="0" decimals="3" blur="changeInput" change="changeInput"></ejs-numerictextbox>


When I save and close the dialog, the grid rounds all decimals. I tried with the "it" and the default "en" localization but the problem is the same.



Do you have a solution?

Thanks in advance.

Regards,

Antonio




RR Rajapandi Ravi Syncfusion Team June 26, 2023 05:20 AM UTC

Hi Customer,


Based on your query we have prepared a sample and tried to reproduce your reported problem at our end, but it was unsuccessful. For your reference, please refer the below working sample and video demo,


Sample:


Video demo:


If you still face any issue, please share the below details that would be helpful for us to provide better solution.


1)             Share your complete Grid rendering code.


2)             Share your Syncfusion package version.


3)             If possible, share any issue reproducible sample or try to reproduce the issue with our above attached sample.



Attachment: vdnumeric_8d189d9a.zip


AN Antonio June 26, 2023 09:04 AM UTC

Hi Ravi,

I tried with Syncfusion.EJ2.AspNet.Core 21.2.10 and 22.1.34. 

Here is my rendering code of Grid


    <ejs-grid id="Grid"
              dataSource="@Model.Articoli"
              toolbar="toolbarItems"
              actionComplete="actionComplete"
              actionFailure="actionFailure"
              allowResizing="true"
              allowSelection="true">
        <e-grid-editSettings allowAdding="true" allowEditing="true" allowDeleting="true" showDeleteConfirmDialog="true" mode="Dialog" template="#dialogTpl"></e-grid-editSettings>
        <e-grid-sortsettings columns="sortCols"></e-grid-sortsettings>
        <e-grid-columns>
            <e-grid-column field="Id" isPrimaryKey="true" visible="false"></e-grid-column>
            <e-grid-column field="Matricola" headerText="Matricola" width="220"></e-grid-column>
            <e-grid-column field="Classe" headerText="Classe" width="80"></e-grid-column>
            <e-grid-column field="Descrizione" headerText="Descrizione" width="auto"></e-grid-column>
            <e-grid-column field="Um" headerText="U.M." width="50" textAlign="Center"></e-grid-column>
            <e-grid-column field="Quantità" headerText="Q.tà" validationRules="@(new { required=true})" format="n1" type="number" width="150" textAlign="Center"></e-grid-column>
            <e-grid-column field="Prezzo" headerText="Prezzo" validationRules="@(new { required=true})" format="c2" type="number" width="150" textAlign="Right"></e-grid-column>
            <e-grid-column field="Totale" headerText="Imponibile" format="c2" type="number" width="150" textAlign="Right"></e-grid-column>
            <e-grid-column field="RifSketch" headerText="Rif. Sketch" width="150"></e-grid-column>
            <e-grid-column headerText="Azioni" width="120" commands="commands" textAlign="Center"></e-grid-column>
        </e-grid-columns>
    </ejs-grid>

This is my model

public class OffertaArticoloViewModel
{
    public int Id { get; set; }

    [StringLength(3)]
    public string Classe { get; set; }

    [StringLength(50)]
    public string Matricola { get; set; }

    [StringLength(2000)]
    public string Descrizione { get; set; }

    public int OpzioneCodice { get; set; }

    public decimal PrezzoAcc { get; set; }

    public decimal Prezzo { get; set; }

    public decimal Sconto { get; set; }

    public decimal PrezzoScontato { get; set; }

    public decimal Quantità { get; set; }

    public decimal TotaleParziale { get; set; }

    public decimal Totale { get; set; }

    [StringLength(3)]
    public string Um { get; set; }

    public string Note { get; set; }
}

This is the partial edit dialog template code

<div class="row">

    <div class="col-2">
        <label asp-for="Um" class="form-label">U.M.</label>
        <ejs-textbox ejs-for="Um" type="text" class="form-control" />
    </div>
    <div class="col">
        <label asp-for="Quantità" class="form-label">Quantità</label>
        <ejs-numerictextbox ejs-for="Quantità" validateDecimalOnType="true" min="0" decimals="3" blur="changeInput" change="changeInput"></ejs-numerictextbox>
    </div>
    <div class="col">
        <label asp-for="Prezzo" class="form-label">Prezzo</label>
        <ejs-numerictextbox ejs-for="Prezzo" format="c2" validateDecimalOnType="true" min="0" decimals="3" blur="changeInput" change="changeInput"></ejs-numerictextbox>
    </div>
    <div class="col">
        <label asp-for="Totale" class="form-label">Imponibile</label>
        <ejs-numerictextbox ejs-for="Totale" format="c2" showSpinButton="false" readonly></ejs-numerictextbox>
    </div>
</div>



Attachment: Grid_rendered_code_cdcc59c7.zip


AN Antonio June 26, 2023 09:41 AM UTC

Attached my demo video.


Attachment: Grid_with_decimals_e592c331.zip


RR Rajapandi Ravi Syncfusion Team July 3, 2023 05:55 AM UTC

Antonio,


We have checked your shared code examples and we could see that you are not shared the code part about definitions of locale. In our previously shared sample, we have loaded the culture files from the cldr files and set the culture and currency code. Please refer the below code example and documentation for more information.


 

<script>

    function loadCultureFiles(name) {

        var files = ['numbers.json', 'timeZoneNames.json', 'currencies.json', 'ca-gregorian.json'];

        var loadCulture = function (prop) {

            var val, ajax;

            ajax = new ej.base.Ajax(location.origin + '/../../scripts/cldr-data/main/' + name + '/' + files[prop], 'GET', true);

            ajax.onSuccess = function (value) {

                val = value;

                ej.base.loadCldr(JSON.parse(val));

            };

            ajax.send();

            ej.base.setCulture('it');

            ej.base.setCurrencyCode('EUR')

        };

        for (var prop = 0; prop < files.length; prop++) {

            loadCulture(prop);

        }

    }

    document.addEventListener('DOMContentLoaded', function () {

        loadCultureFiles('it');

    });

</script>

 


Also, we have checked the response which was return from the server, and it was also returned the proper value at our end. So please ensure once what values are returning from the server after your save action. Please refer the below video demo for more information.


Sample:


Video demo:


Documentation: https://ej2.syncfusion.com/aspnetcore/documentation/common/internationalization


Note: We are not able to run your application at our end, because your shared sample does not contain the EditPartial file.



So, if you still face the issue, please share the runnable application that would be helpful for us to validate or try to replicate your issue in our shared sample.


Attachment: 167681attachments_7cfda774.zip


ST Stefano August 22, 2024 02:27 PM UTC

Are there any updates on the issue?


I'm facing the same. Could it be IT locale vs EN server?



RR Rajapandi Ravi Syncfusion Team August 26, 2024 03:31 AM UTC

Stefano,


After reviewing the information you provided, we understand that you're encountering an issue with the IT locale. However, the details you provided were insufficient for us to fully address your query. To assist you, we've prepared a Grid sample using the IT culture, which worked fine on our end. Please ensure that your application follows the same approach to load the IT culture. For more information, please refer to the code example, sample and documentation provided below.


 

<div>

    @Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>

{

    .  .  .  .  .  .  .  .  .  .

    .  .  .  .  .  .  .  .  .  .

    .  .  .  .  .  .  .  .  .  .

    .  .  .  .  .  .  .  .  .  .

 

}).Locale("it").Render()

</div>

 

<script>

    document.addEventListener('DOMContentLoaded', function () {

        loadCultureFiles('it');

    });

  

    function loadCultureFiles(name) {

        var files = ['numbers.json', 'timeZoneNames.json', 'currencies.json', 'ca-gregorian.json'];

        var loadCulture = function (prop) {

            var val, ajax;

            ajax = new ej.base.Ajax(location.origin + '/../../scripts/cldr/main/' + name + '/' + files[prop], 'GET', true);

            ajax.onSuccess = function (value) {

                val = value;

                ej.base.loadCldr(JSON.parse(val));

            };

            ajax.send();

            ej.base.setCulture('it');

        };

        for (var prop = 0; prop < files.length; prop++) {

            loadCulture(prop);

        }

    }

ej.base.L10n.load({

        'it': {

            'grid': {

"EmptyRecord": "nessun dato da visualizzare",

"True": "vero",

"False": "falso",

"InvalidFilterMessage": "Dati filtro non validi",

.  .  .  .  .  .  .  .

.  .  .  .  .  .  .  .

}

}

});

 

 


Sample:


Documentation: https://ej2.syncfusion.com/aspnetmvc/documentation/common/internationalization#loading-culture-data


Screenshot:



If you still face the issue, please share the below details that would be helpful for us to provide better solution.


1)           Share your complete Grid rendering code, we would like to check how you are loading the IT culture in your application.


2)           Share the issue scenario with video demonstration.


3)           If possible, please try to reproduce the issue with our shared sample that would be helpful for us to provide better solution.


Attachment: 167681sample_11144e2e.zip


ST Stefano September 2, 2024 08:53 AM UTC

Hi Ravi,

The 'it' culture files are loaded correctly. I've managed to find a "solution".

I was initially binding a decimal property in my ViewModel to a NumericTextBox in my grid dialog editor. However, when posting the ViewModel data, the value was being truncated to a whole number (e.g. 1,15 => 1).

To work around this, I tried binding a string property to the numeric TextBox instead. This approach worked well for both rendering and posting. While I understand it's not an ideal solution, it does the job. (e.g. 1,15 => "1,15")

Still not sure why a number, with a locale format, cannot be edited and posted correctly on grid dialog edit, but on inline edit it works.

Ty



RR Rajapandi Ravi Syncfusion Team September 3, 2024 12:25 PM UTC

Stefano,


We are happy to hear that now the IT culture is loaded correctly, and you have found the solution at your end.

Additionally, in your query, you mentioned, "Still not sure why a number, with a locale format, cannot be edited." Since the reported issue only occurs in your application and works correctly on our end, the provided information is insufficient for further validation. We need more details from your side to investigate further.


1)         Share your complete Grid code, including both client-side and server-side, so we can review your Grid initialization.

2)         Share the code that shows how you are binding a decimal property in your ViewModel to a NumericTextBox.

3)         Share your Syncfusion package version.

4)         Share the issue scenario with video demonstration.

5)         Please try to reproduce the issue using the sample we shared, following the same scenario of binding a decimal property in your ViewModel to a NumericTextBox or share any issue reproducible sample that would be helpful for us to provide better solution.


Loader.
Up arrow icon