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

Text for Summary Row

Thread ID:

Created:

Updated:

Platform:

Replies:

60321 May 2,2007 03:57 PM UTC May 30,2007 04:14 PM UTC Windows Forms 8
loading
Tags: GridControl
Vinod
Asked On May 2, 2007 03:57 PM UTC

Hi,

I am using GridGroupingControl to display summaries.

Let my grid has 4 columns,
1] Department
2] SubDepartment
3] Value1
4] Value2

Grouping is done on “Department” and “SubDepartment” columns and SummaryRow shows the aggregated values for “Value1” and “Value2”.

Let values for “Department” are ‘Dept1’ and ‘Dept2’
And values for “SubDepartment” are ‘SubDept1’ and ‘SubDept2’

I want to display text ‘SubDept1 Subtotal’ if the summary is displayed for “SubDepartment” when grouped on ‘SubDept1’ value.
The same approach is used for other values of GroupedColumns.

Can it be achieved in GGC_TableControlPrepareViewStyleInfo event handler? Because I am doing other formatting for SummaryRow in this event handler.

Pls reply ASAP.

Thanks,
Vinod

haneefm [Syncfusion]
Replied On May 2, 2007 05:57 PM UTC

Hi Vinod,

You can handle the TableControlPrepareViewStyleInfo event and set SummaryTitleCell's text usig the e.Style object. Here is a code snippet

private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if( style.TableCellIdentity.TableCellType == GridTableCellType.SummaryTitleCell )
{
Element el = style.TableCellIdentity.DisplayElement;
if( ! el.ParentGroup.IsMainGroup )
{
object category = el.ParentGroup.Category;
if( category != null)
{
e.Inner.Style.Text = category + " Sub Total";
e.Inner.Style.HorizontalAlignment = GridHorizontalAlignment.Left;
}
}
}
}

Please refer to the attached sample for implementation and let me know if this helps.
GGCSummaryCellText.zip

Best regards,
Haneef

Vinod
Replied On May 10, 2007 12:21 PM UTC

Thank you Haneef for the reply.

One more query. Suppose I am grouping on "Department" and "Sub-department". So there will be 2 summary rows will be created. Now depending upon some condition, if I want to hide Summary row for "Department", how will I do that?

Regards,
Vinod

haneefm [Syncfusion]
Replied On May 11, 2007 06:35 PM UTC

Hi Vinod,

My apologies for addressing to the wrong person, it was meant for you.

You can use ShowSummaries property to hide/show the summary row in a grid. Here is a code snippet

//To hide the main table summary row.
this.gridGroupingControl1.TopLevelGroupOptions.ShowSummaries = false;

//To hide all nested table summary row.
this.gridGroupingControl1.NestedTableGroupOptions.ShowSummaries = false;

//To hide all groups summary row.
this.gridGroupingControl1.ChildGroupOptions.ShowSummaries = false;

//To hide a particular grouped column summary row.
this.gridGroupingControl1.TableDescriptor.Columns[ GroupByField ].GroupByOptions.ShowSummaries = false;

If you want to hide a summary row based on some condition, You would have to derive a class from GridGroup. In your derived classes you need to override IsChildVisible.

public override bool IsChildVisible(Element el)
{
if (el is GridSummarySection && this.Records.Count > 2 )
{
return false;
}
else
return base.IsChildVisible(el);// Otherwise default behavior:
}

Here is a minimal sample that shows you " how to hide the summary row based on number of records of group in a grid?".
GGCHideShowSummaryCellText.zip

Best Regards,
Haneef

Vinod
Replied On May 13, 2007 07:04 PM UTC

Haneef,

Thank you very much for the reply.

Cosider following data is displayed in Grid.

Department Sub-Department Value1 Value2
---------- ------------- ------ ------
D1 SD1 10 20
D1 SD1 20 40
D1 SD2 30 60
D1 SD2 40 80

D2 SD3 10 20
D2 SD3 20 40
D2 SD4 30 60
D2 SD4 40 80

Suppose I am grouping on both "Department" and "Sub-department". So 2 summary rows will be created for department and 4 summary rows will be created for sub-department. That's fine.

But if I filter these records on condition "Department = D1", only first four records will be displayed in grid. Now,since Department's value is not changing I want to hide summary row for the Deparment, how it can be done?

If I clear the filter, all 8 records will be displayed in grid and this time summary row for Deparment, should be visible.

Cheers,
Vinod

haneefm [Syncfusion]
Replied On May 14, 2007 05:35 PM UTC

Hi Vinod,

I have modified the attached sample as per your requirement. Please try the attached sample and let me know if this helps.

Sample : ModifiedGGCSummaryCellText.zip

Best regards,
Haneef

Vinod
Replied On May 15, 2007 12:20 PM UTC

Hi Haneef,

I had look at the sample. When the filter is applied, it's hiding all the summary rows.

But my requirement is " To show summary rows only for those Grouped Columns which have multiple values."
So in our example if after filter is added, Department doesn't have multiple values but Sub-department has,
then only "Department Subtotal" should be hidden but "Sub-Department Subtotal" should be displayed.

Also I don't want to display "Grand-Total" summary row in any case.

Cheers,
Vinod

haneefm [Syncfusion]
Replied On May 17, 2007 04:05 PM UTC

Hi Vinod,

If you want to hide a summary row in a grid, then change the return value to false in IsChildVisible override method based on your requirement. Please try the sample and let me know if this helps.

public override bool IsChildVisible(Element el)
{
if( this.ParentTableDescriptor.RecordFilters.Count > 0 )
{
string strGroupName = this.Name;
bool IsSigleValueGroup = this.ParentTableDescriptor.RecordFilters.Contains(strGroupName);

if( el is GridSummarySection && IsSigleValueGroup ) //Hiding the SingleValue GroupColumn.
return false;
else if( this.Category.Equals("Grand")) //Hiding the Grand-Total.
return false;
}
return base.IsChildVisible(el);// Otherwise default behavior:
}

Here is a modified sample
Modified2GGCSummaryCellText.zip

Best regards,
Haneef

Vinod
Replied On May 30, 2007 04:14 PM UTC

Haneef,

Please consider the same example in previous thread.

I am using GridGroupingControl to display summaries.

Let my grid has 4 columns,
1] Department
2] SubDepartment
3] Value1
4] Value2

Grouping is done on “Department” and “SubDepartment” columns and SummaryRow shows the aggregated values for “Value1” and “Value2”.

Now if I want to sort on either “Value1” or “Value2” in ascending order , I want following result:

First sorting will be done on “Department” summary values (highest level group), then “Sub-Department” summary values (lower level group) and then individual records in the same order.

It should work if I want to sort in descending order also.

Can you please send me any sample matching this requirement.

Thanks,
Vinod

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

;