How to get all the GridRecords that belong to a GridCaptionSection groups

I have a single flat datasource that is bound to a ggc.
The ggc is is grouped via..

this.ggc.TableDescriptor.GroupedColumns.Add("SellingTitleName");

.. hence, my ggc looks like this..


GroupCaptionSection
------GridRecord
------GridRecord
------GridRecord
GroupCationSection
-----GridRecord
GroupCaptionSection
-----GridRecord
-----GridRecord

Normally, the GridCaptionCell will display the group name with the number of items, for example ' : 12 items, for example.

My issue is, when the GroupCaptionCell is the currentactivecell, how do i get all the GridRecords that belong to this grouping.

The user wants to right-click on a group and perform an action, for example, delete all the records that below to this grouping.

3 Replies

AD Administrator Syncfusion Team January 23, 2007 11:50 PM UTC

Hi James,

Here is a code snippet that shows you how to get all the GridRecords that belong to a GridCaptionSection in a TableControlCurrentCellActivated event.

private void gridGroupingControl1_TableControlCurrentCellActivated(object sender, GridTableControlEventArgs e)
{
GridCurrentCell cc= e.TableControl.CurrentCell;
Element el = e.TableControl.Table.DisplayElements[cc.RowIndex];
if( el.Kind == DisplayElementKind.Caption )
{
if( el.ParentGroup != null
&& el.ParentGroup.ParentChildTable != null)
{
foreach(Record rec in el.ParentGroup.Records)
Console.WriteLine(rec);
}
}
}

Please refer to the attached sample for implementation.
GGC_Group.zip

Best Regards,
Haneef


JB James Blibo January 24, 2007 12:16 AM UTC

Thanks...

One more question... What if the current cell is a GridRecord? How would you access the GridRecord from this same event 'TableControlCurrentCellActivated'?


JB James Blibo January 24, 2007 12:32 AM UTC

never mind... found it..

if (el.Kind == DisplayElementKind.Record && el.ParentTable != null)
{
Record r = el.ParentTable.CurrentRecord;
}

Loader.
Up arrow icon