Keeping Groups Together in Report Outputs (.NET, C++)

Sorry for the gonzo title of this blog post – I just couldn't resist. I actually started working for combit in 1998 which is a full 18 years ago. And this is the feature I was asked for the most. No kidding. From the early days, way before we had the report container, people wanted this one thing – keep groups together. The reasoning is simple, if you have rather short groups but a huge number of them, you don't want page breaks within one group but rather get a page wrap before the group header and then the whole group on the next page. Totally simple, totally understandable, totally impossible so far.

The reason why we didn’t have this feature for 21 versions is just as logical – in order to know if a group will fit on a page, we’d need to do some kind of lookahead to check and see if it will work out and – if not – rollback and do the wrapping. And it is exactly this lookahead that needs a direct access to the data source. However – at least for .NET and C++, this direct access is available in the form of our Data Provider interface. And so we were finally able to fulfill this request. Using the feature is dead simple, the group header has a new property “Keep Group Together” which you can set to “Yes”.

New feature of version 22

That’s it. Internally, this spawns a two-pass loop where the first pass measures the group lengths and the second then “knows” how much space needs to be reserved for the desired output. So instead of this result, where the sub group “EXC” gets wrapped after the first record although the group only contains two items:

New feature of version 22

You get this, which is much better readable, processable and end user friendly:

New feature of version 22

And while we were at it, we’ve also made sure to extend this feature to sub tables in the report container. This allows you to keep a “master” line together with the full sub table tree on a single page (if it fits, of course). And the same works for table-in-table as well.

Related Posts

Leave a Comment