We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Problem with number formatting in CRUD

Hi,

I have the following Grid:

                        <div>
                            @(Html.EJ().Grid<SlimHub.Models.QuoteSimulationPlantCost>("QuoteSimulationPlantCostsGrid")
                      .Datasource(ds => ds.Json((IEnumerable<QuoteSimulationPlantCost>)Model.QuoteSimulationPlantCosts.ToList()).UpdateURL("../PlantCostEqUpdate").InsertURL("../PlantCostEqInsert").RemoveURL("../PlantCostEqDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
                      .ShowSummary()
                        .SummaryRow(row =>
                        {
                            row.Title("Totale").SummaryColumns(col => { col.SummaryType(SummaryType.Sum).Format("{0:C}").DisplayColumn("TotalPrice").DataMember("TotalPrice").Add(); }).Add();
                        })
                      .EditSettings(edit =>
                      {
                          edit.AllowAdding().AllowDeleting().AllowEditing();
                      })
                      .Locale("it-IT")
                      .ToolbarSettings(toolbar =>
                      {
                          toolbar.ShowToolbar().ToolbarItems(items =>
                          {
                              items.AddTool(ToolBarItems.Add);
                              items.AddTool(ToolBarItems.Edit);
                              items.AddTool(ToolBarItems.Delete);
                              items.AddTool(ToolBarItems.Update);
                              items.AddTool(ToolBarItems.Cancel);
                          }).CustomToolbarItems(
                              new List<object>() {
                                  //new Syncfusion.JavaScript.Models.CustomToolbarItem() {TemplateID = "#Details"},
                                  new Syncfusion.JavaScript.Models.CustomToolbarItem() {TemplateID = "#Details"}});
                      })
                      .AllowResizing()
                      .AllowTextWrap(true)
                      .Columns(col =>
                      {
                          col.Field("PlantCostId").HeaderText("ID").HeaderTextAlign(TextAlign.Center).IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(40).Visible(false).Add();
                          col.Field("QuoteSimId").HeaderText("ID Simulazione").HeaderTextAlign(TextAlign.Center).DefaultValue(Model.QuoteSimId).Width(100).Visible(false).Add();
                          col.Field("EquipmentId").HeaderText("Attrezzatura").ForeignKeyField("EquipmentId").ForeignKeyValue("EquipmentDesc").DataSource((IEnumerable<object>)ViewBag.Equipments).HeaderTextAlign(TextAlign.Center).Width(45).Add();
                          col.Field("Quantity").HeaderText("Quantità").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Format("{0:n1}").Width(80).Add();
                          col.Field("UnitPrice").HeaderText("Prezzo Unitario").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Format("{0:c2}").Width(80).Add();
                          col.Field("TotalPrice").HeaderText("Prezzo Totale").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Format("{0:c2}").AllowEditing(false).Width(80).Add();
                          //col.Field("TotalPrice").HeaderText("Prezzo Totale").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Format("{0:c2}").AllowEditing(false).Width(80).Add();
                          col.Field("Annotations").HeaderText("Note").HeaderTextAlign(TextAlign.Center).Width(80).Add();
                      })
                      .ClientSideEvents(eve =>
                      {
                          eve.ActionComplete("PlantComplete");
                          eve.Create("PlantGridCreate");
                          eve.ToolbarClick("PlantToolBarClick");
                      })
                            )
                        </div>
                    </div>
                </div>

*********************
CRUD METHOD
*********************
        public ActionResult PlantCostEqUpdate(QuoteSimulationPlantCost value)
        {
            if (value.Quantity != null && value.UnitPrice != null)
            {
                value.TotalPrice = value.Quantity*value.UnitPrice;
            }
            else
            {
                value.TotalPrice = null;
            }
            db.Entry(value).State = EntityState.Modified;
            db.SaveChanges();
            return Json(value, JsonRequestBehavior.AllowGet);
        }

When I double click on a grid row and change the note value, the CRUD method is called with the numeric values Quantity and Unit Price not formatted, that is without comma or dot. So, quantity 10,0 is passed as 100, Unit Price of euro 100,00 is passed as 10000. The CRUD methos calculates the total price as Quantity*UnitPrice and returns 100000 euro.

The attached file explains better. 

How can I solve this issue?

Thanks.

Attachment: issue_(2)_bf737b16.zip

1 Reply

TS Thavasianand Sankaranarayanan Syncfusion Team March 22, 2017 05:59 PM UTC

Hi Claudio, 

Thanks for contacting Syncfusion support. 

Query: Problem with number formatting in CRUD 

We have analyzed your query and we are able to reproduce the issue from our end in the version of 14.4.0.20. So, please ensure that you have referred the 14.4.0.20 script file or it’s below version in your sample. 
 
We have fixed the mentioned issue in the latest version of Essential studio so, please upgrade your Essential version to latest(15.1.0.37). 

Regards, 
Thavasianand S. 


Loader.
Live Chat Icon For mobile
Up arrow icon