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
close icon

Retrieving a group''s records in GroupedColumns.Changed event

Hi,

I am using GridGroupingControl v6.303.0.6.

Whenever the user adds or removes a group, I need to retrieve the groups and their Records.

I have a handler attached to the GridGroupingControl.TableDescriptor.GroupedColumns.Changed event. In the handler, I get the groups/Records from GridGroupingControl.Table.TopLevelGroup.Groups. I then recursively iterate the Groups (and their sub-groups, etc..), and process their Records.

Unfortunately, during the GroupedColumns.Changed event the TopLevelGroup.Groups collection has not been updated to include the user's changes yet.

Is there anyway I can get the "up to date" groups/records while handling a GridGroupingControl.TableDescriptor.GroupedColumns.Changed event? Or is there another event I could use?

Currently, as a workaround, I do Thread.Sleep(100) in a background thread, and then invoke back into the UI thread. By then the TopLevelGroup collection is up to date. But this hack makes my stomach hurt :)

1 Reply

JJ Jisha Joy Syncfusion Team June 8, 2010 05:45 AM UTC

Hi Richard,

Thank you for using Syncfusion products.

You could check the e.Action and iterate though the groups to get the uptodate groups. See the code to iterate though the toplevelgroups.


void GroupedColumns_Changed(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)
{
if(e.Action== Syncfusion.Collections.ListPropertyChangedType.Insert || e.Action == Syncfusion.Collections.ListPropertyChangedType.Remove)
{
this.gridGroupingControl1.Table.ExpandAllGroups();
Group grp = this.gridGroupingControl1.Table.TopLevelGroup;
DetailsSection ds = grp.Details;
//group.Records
if (ds is GridRecordsDetails)
{
GridRecordsDetails grd = ds as GridRecordsDetails;
foreach (Record r2 in grd.Records)
{
Console.WriteLine("* " + r2.ToString());
}
}
else
//group.Groups
if (ds is GridGroupsDetails)
{
GridGroupsDetails ggd = ds as GridGroupsDetails;
foreach (Group g in ggd.Groups)
{
Console.WriteLine("+ " + g.ToString());
}
}
}
}


Regards,
Jisha

Loader.
Live Chat Icon For mobile
Up arrow icon