Across not Down!
By Tim Dexter on Feb 14, 2008
As an extension to the article I wrote earlier on getting grouping to work across the page rather than down the page. I received a question from Vidhya at Smart Dog Services - an Oracle partner. Here goes:
In my template I have a table which will have columns like :
When the column is Loads , it has to pouplate the value of commission for Loads (ie 0.4 ), similarly when the column in Transactions, it needs to populate the value of commission for transactions (ie 0.3)
How can I specify this condition in my template
Its another get the grouping across the page not down it. But there is a little wrinkle in here I think. Vidhya sent only a couple of columns of data, I assume that can be dynamic. So we need to handle the possibility of more columns coming in at runtime. We can use the @column and @cell functions to do this - its pretty well documented but you need to play around with it to understand what's going on.
We need a two celled table that looks like this:
The column is going to get repeated for each dynamic column coming into from the data, so set the width as needed. To explain the contents of the fields:
FE Col Desc - <?for-each@column:G_DESCRIPTION?> - this is going to create a new column in the table for every member of the G_DESCRIPTION group that there is
Description - you should be able to work that one out
EFE - closing out the G_DESCRIPTION group
FE Cell Comm - <?for-each@cell:G_COMMISSION?> - creates a cell for every member of the G_COMMISSION group present
Commission - <?COMMISSION?>
EFE - closing the G_COMMISSION group
This gets us the output Vidhya is looking for with the column titles coming from the DESCRIPTION and the values from the COMMISSION element. As more columns come in, the table will fill across the page, once it reaches the edge it will break to a new page. If you have a similar requirement but want to repeat a fixed set of row headers you can use the horizontal-break-table: command.
If you want the columns widths to adjust as columns come into the document then the dynamic columns section in the user guide is going to help you out there.