Hi Rao,
To make sure I understand correctly, the situation you are trying to avoid is that on Page 4 where you have the group heading
"Facility:WESTERN LANDFILL" as the last item on the page, and then Page 5 starting with the detail. With 4GL this was acheived by something like ...
BEFORE GROUP OF facility
NEED 2 LINES
PRINT "Facility: ",
facility.nameON EVERY ROW
PRINT ...
... the end result being that a group heading was never displayed as the last line.
I have been discussing this situation recently with the developers as I have a similar case for one of my clients.
The technique I came up with was to add an empty layout node as the first element of the group
Group facility
Vertical Box (Layout Node) <-- Add this
Facility Header
OnEveryRow
that would have the following properties
X-size=1cm (any value greater than zero)
Y-size=rest>length("M")*2?0:rest
What is this saying ... length("M")*2 equals the amount of vertical space required to render 2 lines (substitute 2 for the value in your NEEDS X LINES),
rest is the amount of space left to draw in the page.
hence rest>length("M")*2 returns TRUE if there is more space left on the page than is required to draw 2 lines, and FALSE otherwise.
So if it returned TRUE, we would set the Y-size of the empty layout box to be 0 and it wouldn't be rendered. If it returned FALSE, it would be rendered and would take up the rest of the remaining space on the page. Whatever was printed after it would be printed on the next page (hence why the empty layout box is the first child element of the group).
An issue with this technique is that length("M") is an educated guess at the space required to draw a line. It performs its calculation using the current font characteristics. When you start having different font characteristics on each line, or lines of variable height, the calculation is not correct. Note: you have the same issue using width("M")*20 to calculate column width. If you change the font characteristics of the heading, the column headings may get wider when the detail headings don't, and the columns no longer match up.
The developers illustrated another technique to me which isn't a literal interpretation of NEEDS X LINES but I think works quite well to acheive a similar effect. Structure your report so that the report structure is
Group facility
Vertical Box (Mini Page)
Facility Header
OnEveryRow
LineDetail
What now happens is that the layouter will attempt to keep a group together on one page where possible. So not only will a page break occur so that the WESTERN LANDFILL facility is on one page, but if you look at Page 1/2, the Belle Glade Transfer Station won't start printing on Page 1 but will start on Page 2. In fact looking at the size of the details for each group, your report will be such that no groups will start on one page and finish on a second page.
This technique isn't perfect as it can lead to the user thinking the report has ended when it hasn't due to the amount of whitespace that can appear on a page. Also I was having trouble with totals. Say a group including totals takes up 1 page + 1 line. I end up with the totals on the second page all on their own wheras in 4GL I'd have
ON EVERY ROW
NEED 2 LINES
PRINT detail
AFTER GROUP OF
PRINT group_total.*
so that a total was never the first line on a page.
Hope that helps, let us know what method you end up using.
Reuben