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

How to iterate grouped values?

I have these values in a DataTable: ZipCode City 93512 Bishop 93514 Bishop 93515 Bishop I initialize my Engine and Table like this: this.m_Engine = new Engine(); this.m_Engine.SetSourceList(this.ZipTable.DefaultView); this.m_Engine.RecordAsDisplayElements = true; this.m_Table = this.m_Engine.Table; I then want to change the grouping to be by city, so I do this: this.m_Table.TableDescriptor.GroupedColumns.Add("City"); I now want to iterate the Records (or Elements?) and have it return to me one row for each grouping level. What collection should I be accessing on the Table object to return that list? Thanks, Sean

2 Replies

AD Administrator Syncfusion Team August 3, 2005 07:48 AM UTC

Under a group, there may be either records or sub-groups. So a group has two properties, group.Groups and group.Records. Only one of these collections is non-null. If the group.Records != null, then the group is showing records and you can iterate through group.Records. If the group.Records is null, then group.Groups should be not null, and you can iterate through that collection. The entries in group.Groups will be a Group object, and you can use their .Category property to see the grouped key.
Group g = this.gridGroupingControl1.Table.TopLevelGroup;
if(g.Records != null)
	//g.Records is populated
	//g.Groups is populated

SG Sean Greer August 3, 2005 07:46 PM UTC

That was just what I needed. Thanks Clay.

Live Chat Icon For mobile
Up arrow icon