Note that this content is intended for users with experience in developing portable view templates.
This article explains how to use tables with portable view tokens in a portable view template, including how to group amounts in tables. Kahua portable view templates use tokens as placeholders for fields from the selected entity (e.g., a memo, an RFI, a contract), or from the project, partition, or domain you are currently in. For more information on how to access portable view template tokens, refer to Portable View Templates - Understanding and Accessing Portable View Tokens. For more general information on portable view templates, refer to Portable View Templates - Overview.
The Table tokens are used to define a Word table with fixed columns and dynamic rows that will output the rows in a repeating fashion against the collection of records the table is bound to. Tables can have zero or more repeating header rows and can also define groupings so that groups can contain summary totals for the grouped attributes.
A table defined in a template will have the [StartTable] token preceded by a paragraph break, then the word table with the desired column layout, the desired header row layout, and the desired data row layout. It is then terminated by the [EndTable] token.
There are two different types of Table tokens supported. For information using parameterized Table tokens, refer to Portable View Templates - Inserting Tables with Parameterized Table Output Tokens.
You can also use XML Table tokens which provide all of the features of the parameterized table tokens but also provide some enhanced capabilities around grouping and totaling data. The use of these tokens is described below.
XML Table Tokens
The XML table tokens provide the same functionality as the parameterized table tokens, but add in some additional grouping and totaling features as described here.
Usage
@[<StartTable Name="uniqueName" Source="<source>" Path="<attributePath>" RowsInHeader="<#>" ShowEmptyTable="<bool>">
<StartTable.Sorts>
<Sort Path="path" Direction="<direction>" />
</StartTable.Sorts>
<StartTable.Grouping GroupMode="<groupMode>" GroupBy="<attribute>" TotalMode="<totalMode>">
<Grouping.Operations>
<Sum>
<Sum.Paths>
<Path SourcePath="<sourceAttributePath>" TargetPath="<targetAttributePath>" />
</Sum.Paths>
</Sum>
<Min>
<Min.Paths>
<Path SourcePath="<sourceAttributePath>" TargetPath="<targetAttributePath>" />
</Min.Paths>
</Min>
<Max>
<Max.Paths>
<Path SourcePath="<sourceAttributePath>" TargetPath="<targetAttributePath>" />
</Max.Paths>
</Max>
<Average>
<Average.Paths>
<Path SourcePath="<sourceAttributePath>" TargetPath="<targetAttributePath>" />
</Average.Paths>
</Average
</Grouping.Operations>
</StartTable.Grouping>
<StartTable.Where>
(<hub conditionals>)
</StartTable.Where>
</StartTable>
Table header row(s) [Attribute Tokens] [TableGroupTotalRow] [TargetPath] [TableTotalRow] [TargetPath]
@[<EndTable />]
The StartTable token elements are as follows:
Element | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<StartTable> Elements |
| ||||||||||||||
<StartTable.Sort> Elements | Optional element used for defining the sort order on the contents of the table data.
| ||||||||||||||
<StartTable.Grouping> Elements | Optional element used to control grouping and totaling operations
| ||||||||||||||
<Grouping.Operations> Elements | Defines the aggregating operations performed on the data in the table. class="even">
| ||||||||||||||
<StartTable.Where> Elements | Optional element used to define filtering conditions for entities included in the table. If defined the Where element contains any Hub conditional expression. |
If a table is to include grouping or totaling, rows must be defined in the Word table with the token [TableGroupRowTotal]
for a group row, and/or a row with the token [TableRowTotal]
for a total row. These tokens designate that the Word Table row will contain content from group or total aggregates and these aggregated results are output by using the various attribute tokens with their path parameter set to the path given in the TargetPath for the various grouping operations defined for the table.
Note that the @[<StartTable>] and @[<EndTable>] tokens must be preceded by a paragraph, the Word paragraphs are used as anchoring characters when placing the generated table within the resulting document. Also note that tables may not have nested containers within them, such as other table or list tokens
Example
The following is an example that shows a table using grouping with subtotals and a grand total line that performs all 4 possible aggregate operations over a set of different attributes.
Template Content:
Code Example:
@[<StartTable Name=”ContractInvoiceItemsTable” Source=”Attribute” Path=”Items” RowsInHeader=”4”>
<StartTable.Sorts> <Sort Path=”ContractItem.Number” Direction=”Ascending” /> </StartTable.Sorts> <StartTable.Grouping GroupMode=”SubTotal” GroupBy=”ContractItem.Id” TotalMode=”Summary”> <Grouping.Operations> <Sum> <Sum.Paths> <Path SourcePath=”ScheduledValue” TargetPath=”SumScheduledValue” /> <Path SourcePath=”PreviousWorkCompleted” TargetPath=”SumPreviousWorkCompleted” /> <Path SourcePath=”WorkCompletedThisPeriod” TargetPath=”SumWorkCompletedThisPeriod” /> <Path SourcePath=”MaterialPresentlyStored” TargetPath=”SumMaterialPresentlyStored” /> <Path SourcePath=”TotalToDate” TargetPath=”SumTotalToDate” /> <Path SourcePath=”BalanceToFinish” TargetPath=”SumBalanceToFinish” /> <Path SourcePath=”TotalRetainage” TargetPath=”SumTotalRetainage” /> </Sum.Paths> </Sum> <Min> <Min.Paths> <Path SourcePath=”ScheduledValue” TargetPath=”MinScheduledValue” /> <Path SourcePath=”PreviousWorkCompleted” TargetPath=”MinPreviousWorkCompleted” /> <Path SourcePath=”WorkCompletedThisPeriod” TargetPath=”MinWorkCompletedThisPeriod” /> <Path SourcePath=”MaterialPresentlyStored” TargetPath=”MinMaterialPresentlyStored” /> <Path SourcePath=”TotalToDate” TargetPath=”MinTotalToDate” /> <Path SourcePath=”BalanceToFinish” TargetPath=”MinBalanceToFinish” /><Path SourcePath=”TotalRetainage” TargetPath=”MinTotalRetainage” /> </Min.Paths> </Min> <Max> <Max.Paths> <Path SourcePath=”ScheduledValue” TargetPath=”MaxScheduledValue” /> <Path SourcePath=”PreviousWorkCompleted” TargetPath=”MaxPreviousWorkCompleted” /> <Path SourcePath=”WorkCompletedThisPeriod” TargetPath=”MaxWorkCompletedThisPeriod” /> <Path SourcePath=”MaterialPresentlyStored” TargetPath=”MaxMaterialPresentlyStored” /> <Path SourcePath=”TotalToDate” TargetPath=”MaxTotalToDate” /> <Path SourcePath=”BalanceToFinish” TargetPath=”MaxBalanceToFinish” /> <Path SourcePath=”TotalRetainage” TargetPath=”MaxTotalRetainage” /> </Max.Paths> </Max> <Average> <Average.Paths> <Path SourcePath=”ScheduledValue” TargetPath=”AvgScheduledValue” /> <Path SourcePath=”PreviousWorkCompleted” TargetPath=”AvgPreviousWorkCompleted” /> <Path SourcePath=”WorkCompletedThisPeriod” TargetPath=”AvgWorkCompletedThisPeriod” /> <Path SourcePath=”MaterialPresentlyStored” TargetPath=”AvgMaterialPresentlyStored” /> <Path SourcePath=”TotalToDate” TargetPath=”AvgTotalToDate” /> <Path SourcePath=”BalanceToFinish” TargetPath=”AvgBalanceToFinish” /> <Path SourcePath=”TotalRetainage” TargetPath=”AvgTotalRetainage” /> </Average.Paths> </Average> </Grouping.Operations> </StartTable.Grouping> <StartTable.Where> <Data Path=”ContractItem” Type=”HasValue” /> </StartTable.Where> </StartTable>]
[EndTable]
Template Output: