Hi Bob,
after you call
Engine.TableDescriptor.GroupedColumns.Add("FIELD1")
you should also call
Engine.TableDescriptor.GroupedColumns.Add("FIELD2")
Then the table will be grouped by field1 and field2 (two levels of grouping).
If you do not want two levels of grouping and group by the pair of both field1/field2 you can add your own custom Categorizer and Comparer object to the SortColumnDescriptor that defines the group.
When a column is grouped, it is first sorted. The Comparer object allows you to control how the sorting is done on your column. Once the column is sorted, the custom Categorizer is used to determine which adjacent records in the sorted column belong to the same group.
To create custom Comparer and Categorizer objects, you define classes that implement either IComparer (one method) or ICategorizer (two methods).
See also the sample at http://www.syncfusion.com/Support/article.aspx?id=10507
Stefan
>Hi,
>
>I''ve converted one of the C# examples for the ASP.NET Grouping control and have it successfully working when grouping by ust the one column. What I can''t figure out is how to add grouping by more than one column.
>
>I''ll explain how I''m doing it and hopefully someone will be able to help.
>
>First I fill a DataSet (called resultsDataSet) by running the following SQL Statement:
>
>SELECT ID, FIELD1, FIELD2 FROM MYTABLE
>
>Then I set the source list and set the column I want to group on:
>
>Private Sub GroupData()
> Engine = New Engine
> Engine.SetSourceList(resultsDataSet.Tables(0).DefaultView)
> Engine.RecordAsDisplayElements = True
> table = Engine.Table
> Engine.TableDescriptor.GroupedColumns.Add("FIELD1")
> Engine.TableDescriptor.Summaries.Add("Count", "ID", SummaryType.DoubleAggregate)
> End Sub
>
>Then I write out a table containing two columns (Field1 and the generated count):
>
>Private Sub DisplayData()
>
> Response.Write("Summary Information when grouped by FIELD1")
> Response.Write("
")
>
> Dim summaries As Syncfusion.Collections.BinaryTree.ITreeTableSummary() = table.TopLevelGroup.GetSummaries(table)
> Dim sdc As SummaryDescriptorCollection = table.TableDescriptor.Summaries
> Dim index As Integer = sdc.IndexOf(sdc("Count"))
> Dim summary As DoubleAggregateSummary
>
> Response.Write("
")
> Response.Write("FIELD1 | Count |
")
>
> Dim g As Group
> Dim idx As DoubleAggregateSummary
>
> For Each g In table.TopLevelGroup.Groups
> summaries = g.GetSummaries(table)
> summary = CType(g.GetSummaries(Me.Engine.Table)(index), DoubleAggregateSummary)
>
> Response.Write("")
> Response.Write(String.Format("{0} | {1} | ", g.Category, summary.Count))
> Response.Write("")
>
> Next
> Response.Write("
")
>
>End Sub
>
>What I am having trouble with is adding another field to the grouping. I want the table to end up looking like:
>
>FIELD1 FIELD2 COUNT
>A A 1
>A B 1
>B A 1
>B B 1
>
>but I can''t figure out how to do it. Can anyone help?
>