Tables (Quick Reference)
Tables display information in a way that makes it easy for end users to visually scan the data. Data series that cannot be aggregated are especially suited for tables. An example can be a list of prices.
Simple Table
https://github.com/pricefx/example-configuration/tree/main/pricefxSrc/CalculationLogic/Dashboard_Chart_Examples/elements/SimpleTable.groovy
ResultMatrix simpleTable(
List<Map> data,
Map<String, String> labels
) {
def table = api.newMatrix()
table.withColumns(labels.keySet())
table.withRows(data)
// Add labels to the columns
labels.each { name, label ->
table.withColumnTranslation(name, ['': label])
}
return table
}
https://github.com/pricefx/example-configuration/tree/main/pricefxSrc/CalculationLogic/Dashboard_Chart_Examples/elements/SimpleTable.groovy
ResultMatrix data = [
[
customerId: 'CD-00001',
label : 'Mega Evil Space Cooperation',
totalSales: 12.8e3,
], [
customerId: 'CD-00001',
label : 'Mom & Pop Store Inc.',
totalSales: 66.0e3,
], [
customerId: 'CD-00001',
label : 'Academy Toddlers',
totalSales: 32.2e3,
]
]
def labels = [
// Do not include the customerId
label : 'Customer Name',
totalSales: 'Total Sales (€)',
]
return simpleTable(data, labels)
Cell Formatting
You can specify exactly how the cells in a column should be formatted with the FielFormatType
enumeration.
https://github.com/pricefx/example-configuration/tree/main/pricefxSrc/CalculationLogic/Dashboard_Chart_Examples/elements/TableWithFormatting.groovy
ResultMatrix tableWithFormatting(
List<Map> data,
Map<String, String> labels,
Map<String, FieldFormatType> formatting
) {
def table = api.newMatrix()
table.withColumns(labels.keySet())
table.withRows(data)
table.withColumnFormats(formatting)
// Add labels to the columns
labels.each { name, label ->
table.withColumnTranslation(name, ['': label])
}
return table
}
Filtering & Sorting
A table header can allow the end user to filter and sort rows according to their field values. Both these features must be switched on by method calls.
https://github.com/pricefx/example-configuration/tree/main/pricefxSrc/CalculationLogic/Dashboard_Chart_Examples/elements/TableWithSortAndSearch.groovy
External Links
A table cell can contain a link to other pages within the frontend application. To turn the cell into a link, simply set the cell value to a string that contains an HTML anchor tag.
https://github.com/pricefx/example-configuration/tree/main/pricefxSrc/CalculationLogic/Dashboard_Chart_Examples/elements/TableWithExternalLinks.groovy
Internal Links
If you want to link to a page within the Pricefx application, it is best to use ResultMatrix.linkCell(). This will ensure that the link that the end user clicks points to a valid page within the same frontend application. Otherwise, there will be issues if the URL changes. For example, if the customer migrates from the Classic frontend application to Unity, all links would still be pointing to Classic.
For a full list of pages that can be targeted with ResultMatrix.linkCell()
, see the reference.
https://github.com/pricefx/example-configuration/tree/main/pricefxSrc/CalculationLogic/Dashboard_Chart_Examples/elements/TableWithInternallLinks.groovy
Cell Styling
Table cells can be styled, for example, to draw attention to certain rows.
https://github.com/pricefx/example-configuration/tree/main/pricefxSrc/CalculationLogic/Dashboard_Chart_Examples/elements/TableQuoteStatus.groovy
Row Actions
End users can be allowed to perform actions on the rows. These actions are strictly limited – they must correspond to a single REST API call.
https://github.com/pricefx/example-configuration/tree/main/pricefxSrc/CalculationLogic/Dashboard_Chart_Examples/elements/TableRowActions.groovy
https://github.com/pricefx/example-configuration/tree/main/pricefxSrc/CalculationLogic/Dashboard_Chart_Examples/elements/TableRowActions.groovy
Row Selection Actions
End users can be allowed to perform actions on selected rows. When one or more rows are selected, a set of action buttons are made available (at the bottom of the table). When one of these buttons is clicked, a callback logic is invoked by the frontend application. This logic must have the default logic nature. An alert will pop up on the screen, indicating whether the execution was successful.
https://github.com/pricefx/example-configuration/tree/main/pricefxSrc/CalculationLogic/Dashboard_Chart_Examples/elements/TableRowSelectionActions.groovy
Set up a bound partition with the name 'thisPartition' that points to the same partition you are using, and add the callback logic.
https://github.com/pricefx/example-configuration/tree/main/pricefxSrc/CalculationLogic/Handler_SubmitQuotes/elements/Handler.groovy
Found an issue in documentation? Write to us.