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.
Syncfusion Feedback

Can i get grid column total ( total freight) when add/edit/delete records

Thread ID:

Created:

Updated:

Platform:

Replies:

126301 Oct 6,2016 12:23 PM UTC Oct 10,2016 11:36 AM UTC ASP.NET Web Forms 3
loading
Tags: Grid
Pratheep
Asked On October 6, 2016 12:23 PM UTC

Hi

Can i get grid column total ( total freight) when add/edit/delete records

       protected void EditAction(string eventType, object record)

        {

            List<Orders> data = Session["DialogDataSource"] as List<Orders>;

            Dictionary<string, object> KeyVal = record as Dictionary<string, object>;

            if (eventType == "endEdit")

            {

 

            }

 

            else if (eventType == "endAdd")

            {

 

            }

 

            else if (eventType == "endDelete")

            {

 

            }

            Session["DialogDataSource"] = data;

            this.OrdersGrid.DataSource = data;

            this.OrdersGrid.DataBind();

 

            getfreight();

        }

 

     private void getfreight()

        {

 

            var gridModel = this.OrdersGrid;

            decimal subtotal = 0; decimal fright = 0;

 

            foreach (Orders gridData in (dynamic)gridModel.DataSource)

            {

                foreach (Syncfusion.JavaScript.Models.Column gridCol in (dynamic)gridModel.Columns)

                {

                    string header = gridCol.HeaderText;

                    if (header == "Freight")

                    {

                        object cellText = gridData.GetType().GetProperty(gridCol.Field).GetValue(gridData, null);

                        string _freight = cellText.ToString();

                        fright = decimal.Parse(_freight.ToString());

                        subtotal = subtotal + fright;

                        txtfreight.Text = subtotal.ToString("####.##");

             

                    }

 

                }

            }

        }


Thanks
Pratheep


Attachment: WebApplication1_2956f1ee.rar

Mani Sankar Durai [Syncfusion]
Replied On October 7, 2016 11:41 AM UTC

Hi Pratheep, 

Thanks for contacting Syncfusion support. 

Since you are trying to get the total value for freight column in the textbox even after performing CRUD operation in grid. 
So for this we have checked your code snippet in the sample that you have provided and found the root cause of an issue, is due to textbox is not rendered inside the update panel so that it didn’t apply the value for the textbox even after performing CRUD operation.  
So we suggest you to render the textbox inside the Asp.Net Update panel. Please refer the below code example, 
[WebForm2.aspx] 
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
        <div> 
        <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
           <ContentTemplate> 
              <asp:TextBox ID="txtfreight" runat="server"></asp:TextBox> 
                <ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" OnServerEditRow="EditEvents_ServerEditRow" OnServerAddRow="EditEvents_ServerAddRow" 
                    OnServerDeleteRow="EditEvents_ServerDeleteRow"> 
 

Also we have feature of Summary Rows in grid to show the Sum, Average, etc.. for the particular column. 
Please refer the below documentation link 
We have also modified a sample that can be downloaded from the below link, 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


Pratheep
Replied On October 8, 2016 10:27 AM UTC

Hi Manisankar

Thank you for your support.working fine


Many thanks
Pratheep

Mani Sankar Durai [Syncfusion]
Replied On October 10, 2016 11:36 AM UTC

Hi Pratheep, 

Thanks for your feedback. 

Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


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.

Warning Icon 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.Close Icon

;