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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grouping Summary Caption Row

Thread ID:

Created:

Updated:

Platform:

Replies:

62889 Jun 25,2007 11:53 AM UTC Jul 3,2007 12:26 AM UTC WinForms 6
loading
Tags: Grouping
Patrick Cheng
Asked On June 25, 2007 11:53 AM UTC

Hi,

I need to create a grid that is grouped by a certain column. Once grouped by that column, I want to be able to add data to the grouped caption row, this data will be similar to the other records under the group. So the columns used will be (and should be) the same.

Is this possible to accomplish?

I have attached an image of what I want to accomplish. Thanks in advanced!

example27.zip

haneefm [Syncfusion]
Replied On June 25, 2007 06:56 PM UTC

Hi Patrick,

You can handle the QueryCellStyleInfo event to set the Style.Text property of the GroupCaptionSummaryCell. See the below code snippet for more details.

[c#]
this.gridGroupingControl1.ChildGroupOptions.ShowCaptionSummaryCells = true;
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Caption
&& e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell )
{
e.Style.Enabled = true;
e.Style.Text = "SomeValue";
}
}

Best regards,
Haneef

Patrick Cheng
Replied On June 26, 2007 01:20 AM UTC

Hi Haneef,

Thanks for your prompt reply. I have tried the method you referred to before, but the problem with it is that it will populate all of the cells of that row with the text "SomeValue". When I try to get the column name by using e.TableCellIdentity.Column.Name, I get a NullReferenceException.

What I need to do is populate different cells of that summary row with different values. Can this be achieved?

Patrick Cheng
Replied On June 26, 2007 02:54 AM UTC

Hi Haneef,

I was able to get the text to be displayed by accessing the column index, this is not ideal, but will work for now.

I have another question. In QueryCellStyleInfo, is there any way to access the value of the caption text? I have set the caption text to be {Category}, but when I check the text at runtime, I get literally {Category}. How can I access what the value of it really is? For example, if the category is Apple, I want to get the text Apple, and not {Category}.

haneefm [Syncfusion]
Replied On June 26, 2007 05:21 PM UTC

Hi Patrick,

Issue 1: Get Column Name.
>>>>>>>>>>>>>>>>>>>>>>>>>
Below are the code snippets that shows you "How to get the column name from the captionrow in a grid?"

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Caption
&& e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell )
{
GridTableDescriptor td = e.TableCellIdentity.DisplayElement.ParentTableDescriptor as GridTableDescriptor;
string ColumnName = string.Empty;
int field = td.ColIndexToField(e.TableCellIdentity.ColIndex);
if (field > -1
&& td.Columns.Count > field )
{
ColumnName = td.Columns[field].Name;
}
object objcategory = e.TableCellIdentity.DisplayElement.ParentGroup.Category;
string scategoryColumnName = e.TableCellIdentity.DisplayElement.ParentGroup.Name;
e.Style.Enabled = true;
e.Style.Text = ColumnName;
Console.WriteLine(objcategory + "___" + scategory);
}
}

Issue 2: Get Caption Category
>>>>>>>>>>>>>>>>>>>>>>>>>
You can use the DisplayElement.ParentGroup.Category property to get the category in a group caption cell. Below is a code snippet

object objcategory = e.TableCellIdentity.DisplayElement.ParentGroup.Category;

Best Regards,
Haneef

Patrick Cheng
Replied On June 28, 2007 01:54 AM UTC

Hi Haneef,

Appreciate your help, it works fine. But now, I want to take it another step. Is it possible for me to update those data in real time? I am subscribing to some external data source that will be sending asynchronous data. When I receive that data, I want to update the fields I put in the Grouping Summary row. I am not sure exactly when the QueryCellStyleInfo event gets called, so if you can shed some light, it would be much appreciated.

Thanks!

haneefm [Syncfusion]
Replied On July 3, 2007 12:26 AM UTC

Hi Patrick,

QueryCellInfo is hit anytime the grid needs a cell style for any reason. So QueryCellInfo is hit prior to PrepareViewStyleInfo, and may be hit for other reasons than preparing the style for drawing. If you use code like grid[row, col], then QueryCellInfo is hit, but PrepareViewStyleInfo may not hit. So, if you are setting a style property that may be of use to you for something other than be drawn a certain way, then you should use QueryCellInfo to set the property dynamically.

Best regards,
Haneef

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

;