Grouping is the most commonly used method to represent data in an organized manner. After designing the basic layout, you may decide to segregate the records by certain fields, or other criteria that would make the report easier to read. By grouping data, you can separate groups of records and display introductory and summary data for each group. The group break is based on a grouping expression. This expression is usually based on one or more recordset fields but it can be as complex as you want.
In FlexReport, grouping is achieved by using FlexReport.Groups. Suppose you want to view a list of products on the basis of suppliers supplying multiple products. In this case, the list should be grouped by Supplier. The following steps illustrate how to Group the list of products by the Supplier. Perform the following steps to perform grouping in the report.
C# |
Copy Code
|
---|---|
<c1:C1FlexViewer Name="flexgrpviewer" HorizontalAlignment="Left" Height="633" VerticalAlignment="Top" Width="958" Margin="0,28,0,0"/> <Button x:Name="btngroup" Content="Group Products by Suppliers" Click="btngroup_Click" HorizontalAlignment="Left" VerticalAlignment="Top" Width="191" Margin="300,5,0,0"/> |
C# |
Copy Code
|
---|---|
Group grp; grp = flexReport.Groups.Add("Supplier", "Supplier", SortEnum.Ascending); C1.WPF.FlexReport.Section s; s = grp.SectionHeader; s.Height = 1000; s.Visible = true; TextField f = new TextField(); f.Name = "Supplier"; f.Text.Expression = "Supplier"; f.Left = 0; f.Top = 0; f.Width = flexReport.Layout.Width; f.Height = 500; f.Align = FieldAlignEnum.LeftMiddle; f.Font.Bold = true; f.Font.Size = 12; f.Border = new C1.WPF.Document.Border(2, Color.FromRgb(0, 0, 0), C1.WPF.Document.DashStyle.Solid); f.BackColor = Color.FromRgb(150, 150, 220); f.MarginLeft = 100; s.Fields.Add(f); flexReport.Render(); |