Overview
Sometimes you encounter a grid or table format that you just cannot figure out how to realize.
A key to solving such tricky cases is understanding what the table row really is. You can then decide how the rows should be created.
Note: This article uses grids as examples, but is equally applicable to tables. The article presumes that you are familiar with SystemWeaver Tables and Grids.
A Simple Example
Consider the following Document example:
You can generate a table of all the Document sections, using this simple script:
<Grid> <Columns> <ItemNameColumn width="200"/> </Columns> <ForEachPart type="IRRS"> <DefObj> <Row/> </DefObj> </ForEachPart> </Grid>
The result you get is this:
Clearly, for this case the rows constitute the Document Section parts (the "IRRS").
Now, what if you want to also include the next subsection level in the grid?
You can do this by just adding an additional column for the subsection parts (the "ISSE"):
Note: We have added the option CellAutoHeight, otherwise we would only see the first subsection of each section. Try removing that option to see for yourself! It should be noted, however, that when used with a very large amount of data, this option can cause some slowness for users during grid generation and viewing. See Managing Performance for Optimized Grid Generation and Viewing for more details.)
<Grid> <Options> <CellAutoHeight/> </Options> <Columns> <ItemNameColumn width="200"/> <ItemNameColumn objectName="subSection" multiValueStyle="NewLineSeparated" width="200"/> </Columns> <ForEachPart type="IRRS"> <DefObj> <Row> <ForEachPart type="ISSE"> <DefObj> <RowObject name="subSection"/> </DefObj> </ForEachPart> </Row> </DefObj> </ForEachPart> </Grid>
(We also had to split the Row element, so that we could add the RowObjects within)
What you get is this:
It is still the Document Sections that constitute the rows. The "A.1" and "A.2" are just multiple lines within the same grid row!
What if you want to list the subsections as proper rows? (this would be required if you also needed to include a column with the subsections of the subsections, etc.)
You can do this by generating the rows, not for each Document Section, but instead for each subsection part:
<Grid> <Options> <CellAutoHeight/> </Options> <Columns> <ItemNameColumn objectName="docSection" cellMerge="True" width="200"/> <ItemNameColumn objectName="subSection" multiValueStyle="NewLineSeparated" width="200"/> </Columns> <ForEachPart type="IRRS"> <DefObj> <RowObject name="docSection"> <ForEachPart type="ISSE"> <DefObj> <RowObject name="subSection"> <Row/> </RowObject> </DefObj> </ForEachPart> </RowObject> </DefObj> </ForEachPart> </Grid>
Note that we have used cellMerge for the document section column, to make the grid look neater:
Kind of similar to the last example, but now, the rows instead represent the subsections, and the corresponding document section name is just included for each subsection row, instead of the other way around.
But what happened to section "C"? It is missing from the grid!
This is a consequence of the decision to make grid rows for each subsection, and document section "C" does not have any...
So, what do you do if you want to also include section "C"?
The key to solving this is to realize that the grid and the script language do not require you to use just a single method for generating the rows. Instead, you can, for instance, generate rows for both Document sections and subsections.
(Of course, you do not want duplicate rows, so you only include rows for Document sections that do not have any subsections, like section "C" in the example, using the condition "/ISSE" which returns true if there are any ISSE parts.)
<Grid> <Options> <CellAutoHeight/> </Options> <Columns> <ItemNameColumn objectName="docSection" cellMerge="True" width="200"/> <ItemNameColumn objectName="subSection" multiValueStyle="NewLineSeparated" width="200"/> </Columns> <ForEachPart type="IRRS"> <DefObj> <RowObject name="docSection"> <Choose> <When test="/ISSE"> <ForEachPart type="ISSE"> <DefObj> <RowObject name="subSection"> <Row/> </RowObject> </DefObj> </ForEachPart> </When> <Otherwise> <Row/> </Otherwise> </Choose> </RowObject> </DefObj> </ForEachPart> </Grid>
Now a row is created for document section "C" as well:
Here, the grid includes four rows. The first three rows correspond to the subsections "A.1", "A.2" and "B.1" respectively, while the last row corresponds to the document section "C".
So, in summary, whenever designing a grid, first decide on what should constitute the rows!
Note: <CellAutoHeight/> is used in the above example, however, it is not recommended if the purpose of the grid is only to export to Excel. See