Printing group footer for every ship city
Now that we have seen how to print a group header and control its printing, let's add a group footer that will display the number of orders from each city. We need to:
- Add a "OrdersPerCity" NumberColumn that will store the number of orders This column will be updated with 0 in the GroupEnter and accumulate its value in the OnLeaveRow
- Add a CitySuffix layout section and place the "OrdersPerCity" column
- Add the GroupLeave and add the WriteTo of the new section
public readonly NumberColumn OrdersPerCity = new NumberColumn("Orders Per City");
public Print_Orders()
{
Groups[Orders1.ShipCity].Enter += () =>
{
_layout.Customer.WriteTo(_ioPrint_Order);
OrdersPerCity.Value = 0;
};
Groups[Orders1.ShipCity].Leave += () =>
{
_layout.GroupLeave.WriteTo(_ioPrint_Order);
};
}
protected override void OnLeaveRow()
{
OrdersPerCity.Value++;
_layout.Body.WriteTo(_ioPrint_Order);
}
And this is the result:
Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com