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

summary row total cell keeps resetting

I need to update my summary row as users edit price and quantities in grid. This code is one of my trials. My dataSource contains list of product descriptions, I then enter the price & quantity and the total is displayed for each row, which in turn update the summary row at the bottom. 
My sum total at the summary row updates properly, but momentarily, but when I continue, the summary is reset to 0 (see pic)

I'm attaching the code and a picture

Attachment: QuestionToSF_6da8e3b6.7z

3 Replies

JK Jayaprakash Kamaraj Syncfusion Team February 3, 2017 11:17 AM UTC

Hi Khaled, 

Thank you for contacting Syncfusion support. 

To overcome this problem, we suggest you to use computed column(Total) using SQL queries. We can create computed column(Total) using SQL queries and also we can calculate Total as Quantity * Price using SQL queries. It will automatically calculate the value when you change the values in relational columns (Quantity / Price) in Grid. So, no need for custom codes to update summary row value. Please refer to the below document. Please refer to the below document    


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


Regards, 

Jayaprakash K. 



KH Khaled February 3, 2017 03:28 PM UTC

This is not a solution. I think you misunderstood my problem. I'm not struggling with how to save it in DB, I am trying to give the user the chance to see those totals, in case he/she wants to amend anything before sending it to the server. 

If you didn't misunderstand me, then I don't know why it is difficult to do with your grid... It is basic need really: qty and price multiplied by each other to get the total and then we need to sum those totals to come up with the grand total, that's it! Almost every grid I've encountered in the past can do this basic need
I currently, can show the total per each row, but per my last thread am struggling with showing the grand total at the bottom. 
Please consult with your peers to see if anyone has an idea on how to achieve this.

I'll wait for your response.



SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team February 6, 2017 12:25 PM UTC

Hi Khaled, 
 
We are sorry for the inconvenience.  
 
Since you have bound the Total column as a template column, you have to manually calculate and update the summary rows. To update this summary row, we suggest to use the Custom Summary for the respective summary column. Refer to the following code example. 
 
@(Html.EJ().Grid<object>("FlatGrid") 
        .Datasource((IEnumerable<object>)ViewBag.dataSource) 
        .AllowPaging()  
        .ShowSummary() 
            .SummaryRow(row => 
                { 
                    row.Title("Sum") 
                        .SummaryColumns(col => { 
                            col.SummaryType(SummaryType.Custom) 
                                .CustomSummaryValue("customValue") 
                                .Format("{0:C}") 
                                .DisplayColumn("TotalPrice") 
                                .DataMember("TotalPrice") 
                                .Add(); 
                        }).Add(); 
                }) 
                   .. . . 
        .Columns(col => 
        { 
           . . . . 
                . . . 
            col.Field("TotalPrice").HeaderText("TotalPrice") 
                .Template("<span class='total'>{{:Freight * EmployeeID }}</span>") 
                .AllowEditing(false) 
                .Add(); 
 
        }) 
) 
<script type="text/javascript"> 
    function customValue(summaryCol, summaryData) { 
        var summaryData1 = 0; 
        var json = summaryData; 
        for (var j = 0; j < json.length; j++) { 
            summaryData1 += json[j].EmployeeID * json[j].Freight; 
        } 
        //summaryData parameter - returns the corresponding dataSource 
        return summaryData1; 
    } 
 
</script> 
 
 
 
We have prepared a sample demo, that can be downloaded from the following location. 
 
 
Regards, 
Seeni Sakthi Kumar S. 


Loader.
Live Chat Icon For mobile
Up arrow icon