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

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

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

3 Replies

MS Mani Sankar Durai Syncfusion Team 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. 



PR Pratheep October 8, 2016 10:27 AM UTC

Hi Manisankar

Thank you for your support.working fine


Many thanks
Pratheep


MS Mani Sankar Durai Syncfusion Team 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. 


Loader.
Live Chat Icon For mobile
Up arrow icon