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. The parameterized Table tokens are described below.
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. For more information, refer to Portable View Templates - Inserting Tables with Parameterized Table Output Tokens.
Parameterized Table Output Tokens
Code Example:
[StartTable(Name=uniqueName,
Source=<source>,
Path=<path>,
RowsInHeader=<#>,
ShowEmptyHeader="<boolean>"
Sort=attribute order[;attribute order],
GroupMode=<groupMode>, GroupBy=<attribute>, GroupTotal=<attribute>, GroupByTotalAttribute=<attribute>, Where.Path=<wherepath>, Where.Operator=operator, Where.Value=<value>,
Where.Conditions=@(<hub conditionals>))]`
Table header row [Attribute Tokens] [EndTable]
The table token parameters are as follows:
Parameter | Description |
Name | The unique name for the table in the template document. Each table token definition must have a unique name. |
Path | Path to the attribute that contains the collection of records. The Path parameter can be omitted, or can use the period (".") path which will bind the table content to the current entity, rather than to a collection of entities in a given attribute. This technique is recommended when using Word tables within the IF/THEN conditional tokens. This is also recommended when defining Word tables in a document that are not going to necessarily contain any bound PV tokens. |
Source | Source of data for Path. |
RowsInHeader | Number of rows in the table header. If not specified this defaults to 0, assuming no header rows in the template table. |
ShowEmptyHeader | Boolean that controls if the table is displayed with just the header rows if no data is present in the table. Default is false. |
Sort | Optional parameter used for specifying the sort order of data in the table. Is used, at minimum a single attribute name should be specified, with an optional space followed by the order, which is Ascending or Descending. If no order is specified, the default is Ascending. If multiple attributes are used for sorting, the attribute order pair is delimited by a semicolon. For example: Sort=Attribute1 Descending;Attribute2 Ascending |
GroupMode | Group mode indicates the type of grouping to be performed. Valid values are:
|
GroupBy | Designates the path to an attribute to group the data by. |
GroupByTotalAttribute | Designates the path to an attribute which is used to retrieve an amount from and total into an aggregated total for the group. |
GroupTotal | Designates the path to an attribute into which the aggregated group total is stored. If used and is to be shown in the document output, the group row in the table should use the attribute name specified here. |
Where.Path | Designates an optional path to an attribute on the Path entities that are used for a conditional evaluation for inclusion in the table output. |
Where.Operator | The operator to use when comparing the Where.Path value to the Where.Value value. If a non-value comparision is used (such as IsNotNull), no Where.Value is required. |
Where.Value | The value to compare the Where.Path value against, if the Where.Operator requires a comparison value. |
Where.Conditions=@(hub conditionals ) | Optional Hub Conditional expression for use of complex conditions for determination of conditional evaluation for inclusion in the table output. |
If a table is to include grouping, a row must be defined in the Word table with the token [TableGroupRowTotal]
which will designate the row for use as the output from a grouping operation.
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.
Examples
This first example shows a simple table with no grouping.
Template Content:
[StartTable(Name=table1,Source=Attribute,Path=Items,RowsInHeader=1)]
[EndTable] |
Template Output:
Number | Description | Amount |
---|---|---|
1 | Item 1 | $300.00 |
2 | Item 2 | $1,500.00 |
3 | Item 3 | $250.00 |
This second example shows a table utilizing sorting and grouping.
Template Content:
[StartTable(Name=table1,Source=Attribute,Path=ContractChangeOrder.Items,RowsInHeader=1,Sort=ItemType Ascending;Number Ascending,GroupMode=SubTotal,GroupBy=ItemType,GroupByTotalAttribute=CostCurrentTotalValue,GroupTotal=GroupTotalValue)]
[EndTable] |
Template Output:
|
Here is another example based upon the data above, but showing the behavior for the GroupMode=Summary.
Template Content:
[StartTable(Name=table1,Source=Attribute,Path=ContractChangeOrder.Items,RowsInHeader=1,Sort=ItemType Ascending;Number Ascending,GroupMode=Summary,GroupBy=ItemType,GroupByTotalAttribute=CostCurrentTotalValue,GroupTotal=CostCurrentTotalValue)]
[EndTable] |
Template Output:
|