This project has moved. For the latest updates, please go here.

Grouping and summerizing in reports

Apr 26, 2013 at 3:21 PM
Hello!
Thank you for the nice reporting tool.
I wonder if it is possible to create something similar to the reports like below?
1.
Image
2.
Image

The data is grouped in the second one. It has parent - Shipment and children ShipmentItems. So would it be possible to layout them like in the picture. If yes what would be the proper way to achieve the goal? If not should I use iTextSharp directly to create such a report?

Thank you in advance.
Coordinator
Apr 26, 2013 at 4:45 PM
Edited Apr 26, 2013 at 4:53 PM
Hello,
PdfReport supports grouping.
Here are some examples which show how to enable grouping:
First you need to sort your data source items properly.
Then specify the grouping formula (how to determine when a new group should be started) by adding the column.Group method:
columns.AddColumn(column =>
                {
                    column.PropertyName("ParentLastName");
                    // ...
                    column.Group(
                    (val1, val2) =>
                    {
                        return val1.ToString() == val2.ToString();
                    });
                });
val1 and val2 are the current and previous values of the current cell here. If those are not equal, a new group will be started (so don't forget to sort data source items).

Also you can set GroupsPreferences:
            .MainTablePreferences(table =>
            {
                // ...
                table.GroupsPreferences(new GroupsPreferences
                {
                    GroupType = GroupType.HideGroupingColumns,
                    RepeatHeaderRowPerGroup = true,
                    ShowOneGroupPerPage = false,
                    SpacingBeforeAllGroupsSummary = 5f,
                    NewGroupAvailableSpacingThreshold = 170
                });
            })
To define custom group headers
  1. Try implementing the IPageHeader interface such as Grouping sample.
  2. or you can use html headers
  3. or try InlineProviders
May 3, 2013 at 5:30 PM
Thank you!
That really helped me.
May 6, 2013 at 3:07 PM
And what would be the best practice to create summary field for invoice like form?
Image

Like what would be the best way to those: "Item sub-total", "Shipping cost", "Less discount" etc. fields below table? I thought I could make it using MainTableSummarySettings -> PageSummarySettings, but only one such setting could be added per page. Can this be customized or could I set more than one PageSummary setting? If not, then what would be the best way to implement this? Should I add footer to each group?
Coordinator
May 6, 2013 at 4:47 PM
Edited May 6, 2013 at 4:47 PM
Hello,
You need to use events to add custom summaries per page, report or group.
Here you can find 2 samples about