Open navigation

Portable View Templates - Inserting Tables with Parameterized Table Output Tokens

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:


ParameterDescription
NameThe unique name for the table in the template document. Each table token definition must have a unique name.
PathPath 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.
SourceSource of data for Path.
RowsInHeaderNumber of rows in the table header. If not specified this defaults to 0, assuming no header rows in the template table.
ShowEmptyHeaderBoolean 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:

  • None - the default which is no grouping is applied.
  • Default or SubTotal - grouping is performed on the items in the GroupBy attribute with the individual rows output and a grouping row output following the individual rows.
  • Summary - grouping is performed on the items in the GroupBy attribute but only the grouping row is output.

GroupByDesignates the path to an attribute to group the data by.
GroupByTotalAttributeDesignates the path to an attribute which is used to retrieve an amount from and total into an aggregated total for the group.
GroupTotalDesignates 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.PathDesignates an optional path to an attribute on the Path entities that are used for a conditional evaluation for inclusion in the table output.
Where.OperatorThe 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.ValueThe 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)]

[NumberLabel][DescriptionLabel][AmountLabel]
[Attribute(Number)][Attribute(Description)][Currency(Path=Amount)]

[EndTable]


Template Output:

NumberDescriptionAmount
1Item 1$300.00
2Item 2$1,500.00
3Item 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)]

[NumberLabel][DescriptionLabel][ActivityCodeLabel][AmountLabel]
[Attribute(Number)][Attribute(Description)][Attribute(WorkbreakdownItem.Code)][Currency(Path=CostCurrentTotalValue)]
[TableGroupTotalRow][Attribute(ItemType)] Total[Currency(Path=GroupTotalValue)]

[EndTable]

Template Output:

NumberDescriptionActivity CodeAmount
1Parts301.1$300.00
2More Parts2301.2$1,500.00
Parts Total$1,800.00
3Plumbing401.1$500.00
4Pipes401.2$600.00
Plumbing Total$1,100.00
5Electrical501.1$700.00
6Wiring501.2$800.00
Electrical Total$1,500.00


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)]

[NumberLabel][DescriptionLabel][ActivityCodeLabel][AmountLabel]
[TableGroupTotalRow][Attribute(ItemType)] Total[Currency(Path=GroupTotalValue)]

[EndTable]

Template Output:

NumberDescriptionActivity CodeAmount
Parts Total$1,800.00
Plumbing Total$1,100.00
Electrical Total$1,500.00


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.