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

Retrieving GridSummaryColumnDescriptor column in QueryCellStyleInfo event

if I have previous defined a GridSummaryColumnDescriptor and added it to an summary row

GridSummaryColumnDescriptor sd1 = new GridSummaryColumnDescriptor();
sd1.Name = "QuantityTotal1";
sd1.DataMember = "Quantity1";


GridSummaryColumnDescriptor sd2 = new GridSummaryColumnDescriptor();
sd2.Name = "QuantityTotal2";
sd2.DataMember = "Quantity2";

this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("Row 1", "Total", new GridSummaryColumnDescriptor[] {sd1,sd1}));


How do I retrieve specific summary column in the
QueryCellStyleInfo event from the GridColumnDescriptor column as described below?

// you can get the column as follows:
GridColumnDescriptor column = e.TableCellIdentity.Table.GetColumnDescriptorAt(e.Style.TableCellIdentity.RowIndex+1, e.Style.TableCellIdentity.ColIndex);


// Using that column above, how can i and identify the summary that should be displayed in this cell.


3 Replies

AD Administrator Syncfusion Team September 4, 2006 05:22 AM UTC

Hi James,

You can use the GetSummaryColumnAtCol method to get the GridSummaryColumnDescriptor in a grid. The GridSummaryColumnDescriptor.DisplayColumn property lets you specify under which column the summary should be displayed in the grid. GridSummaryColumnDescriptor elements that are added to the same row descriptor will be shown in the same row. Below is a code snippet

GridSummaryColumnDescriptor sd = e.TableCellIdentity.Table.TableDescriptor.SummaryRows["Row 1"].GetSummaryColumnAtCol(e.Style.TableCellIdentity.ColIndex);

Let me know if this helps.
Best Regards,
Haneef



JA jamesb September 4, 2006 08:06 AM UTC

This is still not working ro me. I do get a reference to the

GridSummaryColumnDescriptor col1 = new GridSummaryColumnDescriptor("sumCol1", SummaryType.Int32Aggregate, "[8/7/2006]", "{Sum:#}");
GridSummaryColumnDescriptor col2 = new GridSummaryColumnDescriptor("sumCol2", SummaryType.Int32Aggregate, "[8/14/2006]", "{Sum:#}");
GridSummaryColumnDescriptor col3 = new GridSummaryColumnDescriptor("sumCol3", SummaryType.Int32Aggregate, "[8/21/2006]", "{Sum:#}");
GridSummaryColumnDescriptor col4 = new GridSummaryColumnDescriptor("sumCol4", SummaryType.Int32Aggregate, "[8/28/2006]", "{Sum:#}");

GridSummaryRowDescriptor row = new GridSummaryRowDescriptor("Caption", "CaptionTitle", new GridSummaryColumnDescriptor[] { col1, col2, col3, col4 });
row.Visible = false;
this.gridGroupingControl.TableDescriptor.SummaryRows.Add(row);


In the QueryCellStyleInfo event, I have something like this...

if ( (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell || e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell))
{
Group group = e.TableCellIdentity.DisplayElement.ParentGroup;
GridTable table = e.TableCellIdentity.DisplayElement.ParentTable as GridTable;

GridSummaryRowDescriptor summaryRowDescriptor = table.TableDescriptor.SummaryRows["Caption"];
GridSummaryColumnDescriptor sumCol1 = summaryRowDescriptor.SummaryColumns[colIndex - 5];

if (sumCol1 != null)
{
SummaryDescriptor sd1 = sumCol1.SummaryDescriptor;
if (sd1 != null)
{

ISummary groupSummary = this.gridGroupingControl.Table.TopLevelGroup.GetSummary(colIndex - 5);
Int32AggregateSummary int32Summary = (Int32AggregateSummary)groupSummary;
int sum = int32Summary.Sum;
int max = int32Summary.Maximum;
int cnt = int32Summary.Count;

}
}
}

However, sum, max, and cnt arte always zero. What am I doing wrong?


JA jamesb September 4, 2006 08:52 AM UTC

I fix it... change date "[8/21/2006]" to "8/21/2006"

Loader.
Live Chat Icon For mobile
Up arrow icon