GridSummaryRowDescriptor if Event for clicking on the column
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,
SIGN IN To post a reply.
7 Replies
AA
Arulraj A
Syncfusion Team
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
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 thethis.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
AA
Arulraj A
Syncfusion Team
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
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
GP
Gregory Pe
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 ..
AA
Arulraj A
Syncfusion Team
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
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 exampleprivate 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
AA
Arulraj A
Syncfusion Team
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
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
SIGN IN To post a reply.
- 7 Replies
- 2 Participants
-
GP Gregory Pe
- Nov 20, 2018 12:56 PM UTC
- Nov 23, 2018 04:13 AM UTC