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.
Unfortunately, activation email could not send to your email. Please try again.

Problem with cell number format after inline editing

Thread ID:

Created:

Updated:

Platform:

Replies:

125673 Sep 1,2016 11:08 AM Sep 8,2016 12:48 AM ASP.NET MVC 10
loading
Tags: Grid
CLAUDIO RICCARDI
Asked On September 1, 2016 11:08 AM

Hi,

I've got a problem with parsing of a decimal number after inline editing.

I have defined a grid like this:

                <div class="Row">
                    <div class="Column">
                        <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))
                      .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);
                          });
                      })
                      .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("Product").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("Annotations").HeaderText("Note").HeaderTextAlign(TextAlign.Center).Format("{0:c2}").Width(80).Add();
                      })
                      .ClientSideEvents(eve =>
                      {
                          //eve.ActionComplete("complete").ActionBegin("begin").EndEdit("endEdit").EndAdd("endAdd");
                          eve.EndEdit("plantEndEdit");
                      })
                            )
                        </div>
                    </div>
                </div>

When I try to change the value of a numeric cell (either Quantity value or UnitPrice value) the following controller method is called:

        public ActionResult PlantCostEqUpdate(QuoteSimulationPlantCost value)
        {
            db.Entry(value).State = EntityState.Modified;
            db.SaveChanges();
            //db.Settings.Update(value);
            var data = db.QuoteSimulations.ToList();
            return Json(value, JsonRequestBehavior.AllowGet);
        }

If the value typed in the grid cell is, for example, 10,0, in the object passed as parameter of the method I see 100, thai is the number without comma separator for decimal digits.

How can I set the value of the TotalPrice column to be the value of UnitPrice multiplied by Quantity?

Thanks.

Claudio


Jayaprakash Kamaraj [Syncfusion]
Replied On September 2, 2016 08:01 AM

Hi Claudio, 
 
Thank you for contacting Syncfusion support. 
 
Query 1: If the value typed in the grid cell is, for example, 10,0, in the object passed as parameter of the method I see 100, thai is the number without comma separator for decimal digits. 
 
We have created sample based on your requirement but we are unable reproduce the issue at our end. Please refer to the below video. 
 
 
 Please share the following information to find the cause of the issue.  
                                                                                                                
1.       Share the video to show the issue. 
2.       Issue replication procedure. 
3.       Essential studio and browser version details. 
4.       System settings corresponding to Number format. 
5.       An issue reproducing sample if possible or replicate the issue in the following sample 
 

Query 2: How can I set the value of the TotalPrice column to be the value of UnitPrice multiplied by Quantity? 

We have achieved your requirement using queryCellInfo event. This event is triggered, every time when a request is made to access a particular cell information, element, and data. In this event, we can set text for cells only for display purpose. Please refer to the Help document, code example and sample. 

 
@(Html.EJ().Grid<object>("FlatGrid") 
           .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).InsertURL("/Grid/PerformInsert") 
                                .UpdateURL("/Grid/PerformUpdate") 
                                .RemoveURL("/Grid/PerformDelete").Adaptor(AdaptorType.RemoteSaveAdaptor)) 
        … 
            
        }).ClientSideEvents(eve=>eve.QueryCellInfo("querycellinfo"))) 
<script type="text/javascript"> 
    function querycellinfo(args) { 
        if (args.column.field == "TotalPrice") { 
            $(args.cell).text(args.data.EmployeeID * args.data.Freight);//For display purpose 
        } 
    
    } 
</script> 


Regards, 

Jayaprakash K. 


CLAUDIO RICCARDI
Replied On September 5, 2016 05:14 AM

Hi,

thank you for your answer.

I have solved point 2 but I still have problems with point 1.

When I load the Edit page I see the following error message:

<<ej.culture.it-IT.min.js:1 Uncaught TypeError: ej.addCulture is not a function>>

This is the include scripts order I have in the _Layout.cshtml file:

    <link rel='nofollow' href="@Url.Content("~/Content/font-awesome/css/font-awesome.min.css")" rel="stylesheet" />
    <link rel='nofollow' href="@Url.Content("~/Content/ej/web/Default-theme/ej.widgets.all.min.css")" rel="stylesheet"/>

    <script src="@Url.Content("~/Scripts/jquery-1.10.2.min.js")"></script>
    <script src="@Url.Content("~/Scripts/jsrender.min.js")"></script>
    <script src="@Url.Content("~/Scripts/jquery.easing.1.3.min.js")"></script>
    <script src="@Url.Content("~/Scripts/jquery.globalize.min.js")"></script>
    <script src="@Url.Content("~/Scripts/ej/ej.web.all.min.js")"></script>
    <script src="@Url.Content("~/Scripts/ej/ej.unobtrusive.min.js")"></script>
    <script src="@Url.Content("~/Scripts/ej/ej.culture.it-IT.min.js")"></script>

I can't understand what is the cause uf this error...

Prasanna Kumar Viswanathan [Syncfusion]
Replied On September 5, 2016 06:51 AM

Hi Claudio, 

Query 1: “How can I set the value of the TotalPrice column to be the value of UnitPrice multiplied by Quantity?”  

We are happy to hear that your issue has been resolved. 
 
Query 2: “<<ej.culture.it-IT.min.js:1 Uncaught TypeError: ej.addCulture is not a function>>” 
 
We checked with our sample by defining the script files with the mentioned order and we did not face any script error when we load the edit page. 
 
Please share the following information to find the cause of the issue. 

1. Did you face this issue in particular browser or in all browsers? 
 
2. Essential Studio Version details. 
 
3. Share the stackrace of a script error. 
 
4. If possible, replicate the issue in the attached sample. 
 
 
Regards, 
 
Prasanna Kumar N.S.V 


CLAUDIO RICCARDI
Replied On September 5, 2016 09:40 AM

I have tested the page with the following browsers and the problem still appears:

- Chrome (ver 52.0.2743)
- Internet Explorer (ver 11.545.10586)

In Internet Explorer I don't see the error but even if I set .Locale("it-IT"), the $ currency symbol is used.

- Essential Studio (ver. 14.2.0.26)

Stacktrace of script error

ej.culture.it-IT.min.js:1 Uncaught TypeError: ej.addCulture is not a function
(anonymous function) @ ej.culture.it-IT.min.js:1



CLAUDIO RICCARDI
Replied On September 5, 2016 11:30 AM

Ok, problem solved.

The script ej.web.all.min.js was out of date. After using the last version of the script everything went ok.

Thanks a lot for your support.

Best Regards.

Claudio

Jayaprakash Kamaraj [Syncfusion]
Replied On September 6, 2016 12:31 AM

Hi Claudio,  
 
We are happy to hear that your issue has been resolved.  
 
Please get back to us if you need any further assistance.   
 
Regards,  
 
Jayaprakash K. 


CLAUDIO RICCARDI
Replied On September 6, 2016 05:22 AM

Hi, Jayaprakash K. 

I have another question:

I would like to have the sum of a grid's column copied into a numeric textbox.

The logical steps are these:

1) In the grid I can modify (in inline mode) either UnitPrice or Quantity and the column TotalPrice is recalculated
2) After modifications in step 1 the new values of the row are saved into database
3) The sum of the TotalPrice column is to be copied into a numerictextbox outside of the grid.

Using queryCellInfo event lets me correctly update the cell value but how can I force the data to be saved into database?

And then, how can I get the sum of the TotalPrice column so that I can copy it into the textbox?

Thanks in advance.

Claudio

Jayaprakash Kamaraj [Syncfusion]
Replied On September 7, 2016 08:40 AM

Hi Claudio, 

Query 1: how can I force the data to be saved into database? 

We have created computed column(TotalPrice) using SQL queries. Here, we have calculated TotalPrice as EmployeeID * Freight using SQL queries. While using computed column, QueryCellInfo event is not necessary and also it will automatically calculate the value when you change the values in relational columns (EmployeeID / Freight) in Grid. Please refer to the below document    



ALTER TABLE dbo.OrderTables DROP COLUMN TotalPrice;   
GO   
ALTER TABLE dbo.OrderTables ADD TotalPrice AS (EmployeeID * Freight ); 


Query 2: how can I get the sum of the TotalPrice column so that I can copy it into the textbox? 
 
We have achieved your requirement using DataBound and ActionComplete event. In this event, we have calculated total summary value and then displayed in numeric textbox. Please refer to the below help documents, code example and sample.   
 
Help documents for, 
 
 
 
<div> 
    TotalPrice: <input id="TotalFreight" type="text" width="200" /> 
</div> 
@(Html.EJ().Grid<object>("FlatGrid") 
.. 
        .Columns(col => 
        { 
.. 
            col.Field("TotalPrice").HeaderText("TotalPrice").Width(80).Add(); 
            col.Field("OrderDate").HeaderText("Order  
             
        }).ClientSideEvents(eve=>eve.DataBound("databound").ActionComplete("actioncomplete"))) 
<script type="text/javascript"> 
    var total = 0; 
    function databound(args) { 
        total = ej.sum(this.model.dataSource.dataSource.json, "TotalPrice"); 
        $("#TotalFreight").val(total); 
        } 
    function actioncomplete(args) { 
        if (args.requestType == "save" || args.requestType == "delete") { 
            total = ej.sum(this.model.dataSource.dataSource.json, "TotalPrice"); // here we have calculated summary for whole dataSource , if you want to display summary for current page only means use  
this. model.currentViewData 
 
            $("#TotalFreight").val(total); 
        } 
    } 
 
 
</script>  


Regards, 

Jayaprakash k. 


CLAUDIO RICCARDI
Replied On September 7, 2016 11:56 AM

Thanks a lot for your very professional support.

Claudio

Jayaprakash Kamaraj [Syncfusion]
Replied On September 8, 2016 12:48 AM

Hi Claudio, 
 
Thanks for the update. 
 
Please get back to us for further assistance. 
 
Regards, 
 
Jayaprakash K. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;