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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridSummaryRowDescriptor if Event for clicking on the column

Thread ID:

Created:

Updated:

Platform:

Replies:

141048 Nov 20,2018 12:56 PM UTC Nov 23,2018 04:13 AM UTC WinForms 7
loading
Tags: GridGroupingControl
Gregory Pe
Asked On November 20, 2018 12:56 PM UTC

Hello,

Currently i have a GGC and i have a _ClickCell event on that grid.

 I use this event to see
 if the user has clicked on any column  in one specific column and perform some actions based on that.

I need it to dynamically add a summary row (GridSummaryRowDescriptor) for that column
with the sum (if it is a number) in the clicked column


Thanks in advance,

Arulraj A [Syncfusion]
Replied On November 21, 2018 09:27 AM UTC

Hi Gregory, 

Thanks for using Syncfusion product. 

To add the summary while click on the column, you could use the GridTableCellStyleInfo and SummaryRows in TableControlCellClick event. Please refer the following code example, 

Code example 
this.gridGroupingControl1.TableControlCellClick += GridGroupingControl1_TableControlCellClick; 
 
private void GridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e) 
{ 
    if (e.TableControl.CurrentCell.MoveFromColIndex == e.TableControl.CurrentCell.ColIndex) 
        return; 
 
    GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex); 
    if (style.CellValueType == typeof(int)) 
    { 
        if (style.TableCellIdentity != null && style.TableCellIdentity.Column != null) 
        { 
            string columnName = style.TableCellIdentity.Column.Name; 
            if (this.gridGroupingControl1.TableDescriptor.SummaryRows.Count > 0) 
                //Clear the previous summary rows to add the  
                this.gridGroupingControl1.TableDescriptor.SummaryRows.Clear(); 
 
            GridSummaryColumnDescriptor scd = new GridSummaryColumnDescriptor(); 
            scd.SummaryType = Syncfusion.Grouping.SummaryType.Int32Aggregate; 
            scd.Format = "{Sum}"; 
            scd.DataMember = columnName; 
            scd.Name = "SumOf" + columnName; 
 
            GridSummaryRowDescriptor srd = new GridSummaryRowDescriptor("Row1", scd); 
            this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(srd); 
            //To update the summary. 
            this.gridGroupingControl1.TableDescriptor.EnsureSummaryDescriptors(); 
        } 
    } 
} 
 

Arulraj A 


Gregory Pe
Replied On November 21, 2018 04:12 PM UTC

Hi Gregory, 

Thanks for using Syncfusion product. 

To add the summary while click on the column, you could use the GridTableCellStyleInfo and SummaryRows in TableControlCellClick event. Please refer the following code example, 

Code example 
this.gridGroupingControl1.TableControlCellClick += GridGroupingControl1_TableControlCellClick; 
 
private void GridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e) 
{ 
    if (e.TableControl.CurrentCell.MoveFromColIndex == e.TableControl.CurrentCell.ColIndex) 
        return; 
 
    GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex); 
    if (style.CellValueType == typeof(int)) 
    { 
        if (style.TableCellIdentity != null && style.TableCellIdentity.Column != null) 
        { 
            string columnName = style.TableCellIdentity.Column.Name; 
            if (this.gridGroupingControl1.TableDescriptor.SummaryRows.Count > 0) 
                //Clear the previous summary rows to add the  
                this.gridGroupingControl1.TableDescriptor.SummaryRows.Clear(); 
 
            GridSummaryColumnDescriptor scd = new GridSummaryColumnDescriptor(); 
            scd.SummaryType = Syncfusion.Grouping.SummaryType.Int32Aggregate; 
            scd.Format = "{Sum}"; 
            scd.DataMember = columnName; 
            scd.Name = "SumOf" + columnName; 
 
            GridSummaryRowDescriptor srd = new GridSummaryRowDescriptor("Row1", scd); 
            this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(srd); 
            //To update the summary. 
            this.gridGroupingControl1.TableDescriptor.EnsureSummaryDescriptors(); 
        } 
    } 
} 
 

Arulraj A 


thank you

Arulraj A [Syncfusion]
Replied On November 22, 2018 06:14 AM UTC

Hi Gregory,

Thanks for the update.

We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you.

Regards,
Arulraj A

Gregory Pe
Replied On November 22, 2018 06:53 AM UTC

Hi Arulraj A

how to do that
1.
  after clicking the next column, GridSummaryColumnDescripto did not disappear
so that the second, third ...
2.
when we click the second time in the same column - it should disappear only in what we clicked a second time
- when we click the third time it adds again ..


Gregory

Arulraj A [Syncfusion]
Replied On November 22, 2018 12:26 PM UTC

Hi Gregory, 

Thanks for your update. 

Query 
Response 
  

 
 
 
 
 
after clicking the next column, GridSummaryColumnDescripto did not disappear
so that the second, third 
 











To add the new column, you could create the GridsummaryColumnDescriptor for that column the add this summary column in SummaryRows collection.  If want to remove the column from summary columns when click on the same column, you could check and remove that column from SummaryColumns collection. Please refer the following code example 

Code example 
private void GridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e) 
{ 
    GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex); 
    if (style.CellValueType == typeof(int)) 
    { 
        if (style.TableCellIdentity != null && style.TableCellIdentity.Column != null) 
        { 
            string columnName = style.TableCellIdentity.Column.Name; 
 
            GridSummaryColumnDescriptor scd = null; 
            if (this.gridGroupingControl1.TableDescriptor.SummaryRows.Count == 0) 
            { 
                scd = AddSummaryColumn(columnName); 
                GridSummaryRowDescriptor srd = new GridSummaryRowDescriptor(); 
                this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(srd); 
            } 
 
            GridSummaryRowDescriptor summaryRow = this.gridGroupingControl1.TableDescriptor.SummaryRows[0]; 
            var summarycolDescriptor = summaryRow.SummaryColumns.Cast<GridSummaryColumnDescriptor>().Where(x => x.DataMember == columnName); 
            if (summarycolDescriptor.Count() > 0) 
            { 
                var value = summarycolDescriptor.ToList()[0]; 
                summaryRow.SummaryColumns.Remove(value); 
            } 
            else 
            { 
                scd = AddSummaryColumn(columnName); 
                summaryRow.SummaryColumns.Add(scd); 
 
            } 
            //To update the summary. 
            this.gridGroupingControl1.TableDescriptor.EnsureSummaryDescriptors(); 
        } 
    } 
} 
when we click the second time in the same column - it should disappear only in what we clicked a second time 
- when we click the third time it adds again 


Arulraj A 


Gregory Pe
Replied On November 22, 2018 01:03 PM UTC

Hi Gregory, 

Thanks for your update. 

Query 
Response 
  

 
 
 
 
 
after clicking the next column, GridSummaryColumnDescripto did not disappear
so that the second, third 
 











To add the new column, you could create the GridsummaryColumnDescriptor for that column the add this summary column in SummaryRows collection.  If want to remove the column from summary columns when click on the same column, you could check and remove that column from SummaryColumns collection. Please refer the following code example 

Code example 
private void GridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e) 
{ 
    GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex); 
    if (style.CellValueType == typeof(int)) 
    { 
        if (style.TableCellIdentity != null && style.TableCellIdentity.Column != null) 
        { 
            string columnName = style.TableCellIdentity.Column.Name; 
 
            GridSummaryColumnDescriptor scd = null; 
            if (this.gridGroupingControl1.TableDescriptor.SummaryRows.Count == 0) 
            { 
                scd = AddSummaryColumn(columnName); 
                GridSummaryRowDescriptor srd = new GridSummaryRowDescriptor(); 
                this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(srd); 
            } 
 
            GridSummaryRowDescriptor summaryRow = this.gridGroupingControl1.TableDescriptor.SummaryRows[0]; 
            var summarycolDescriptor = summaryRow.SummaryColumns.Cast<GridSummaryColumnDescriptor>().Where(x => x.DataMember == columnName); 
            if (summarycolDescriptor.Count() > 0) 
            { 
                var value = summarycolDescriptor.ToList()[0]; 
                summaryRow.SummaryColumns.Remove(value); 
            } 
            else 
            { 
                scd = AddSummaryColumn(columnName); 
                summaryRow.SummaryColumns.Add(scd); 
 
            } 
            //To update the summary. 
            this.gridGroupingControl1.TableDescriptor.EnsureSummaryDescriptors(); 
        } 
    } 
} 
when we click the second time in the same column - it should disappear only in what we clicked a second time 
- when we click the third time it adds again 


Arulraj A 


Hi Arulraj A

perfectly
thank you for the quick reply


Gregory

Arulraj A [Syncfusion]
Replied On November 23, 2018 04:13 AM UTC

Hi Gregory,

Thanks for the update.

We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you.

Regards,
Arulraj A

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon