Open navigation

Portable View Templates - Inserting Tables with XML Table 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. 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:


ElementDescription
<StartTable> Elements
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. See Token Source (Parameter). Defaults to Attribute.
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.

<StartTable.Sort> ElementsOptional element used for defining the sort order on the contents of the table data.

ParameterDescription
PathAttribute path data is sorted on
Direction

Direction of sort. Default is Ascending. If grouping is used a sort must be specified. Valid values are:





  • Ascending




  • Descending




<StartTable.Grouping> ElementsOptional element used to control grouping and totaling operations

ParameterDescription
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. Note that the summary row must be defined in the table content designated using the [TableGroupTotalRow] token.



GroupByDesignates the path to an attribute to group the data by.
TotalMode

Total mode indicates that running aggregates are determined over all data in the table using the designated operations. Valid values are:





  • None - the default which is no total is calculated or output




  • Summary - a total is output. A total row must be defined in the table content designated using the [TableTotalRow] token




<Grouping.Operations> ElementsDefines the aggregating operations performed on the data in the table. class="even">

ParameterDescription
Operation (<Sum>)/(<Min>)/(<Max>)/(<Average>) ElementsOperation elements are the optional mathematical operations that can be performed over grouped rows. The respective elements Sum, Min, Max, and Average define the operation performed on the referenced paths. Define the respective operation only if the given operation is needed for the table content (e.g. Sum if a sum is required)
Operation.PathsContains a set of Path elements that define the source attributes the operation (Sum/Min/Max/Average) is performed on
<Path> ElementPath element defines a source attribute an operation is performed against and the target manufactured attribute the result is stored in for output








ParameterDescription
SourcePathThe path to the attribute to use as the source of the aggregate operation

TargetPath
The path to the manufactured attribute the result of the aggregate operation is stored in. This path name is what is used to output the grouped or totaled result in the group or total rows in the table


<StartTable.Where> ElementsOptional 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]



screenshot_2024-02-22_155020.png



Template Output: 
screenshot_2024-02-22_155603.png


 




Did you find it helpful? Yes No

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