Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 109 Current »

Sometimes you need to display a table in a Dashboard, Quote, Price List or any other document, for example:

  • Dashboard — As a table in a portlet.

    ResultMatrixScreenshot
  • Price List — A button will open an overlayed panel with the table.

  • Quote — A button will open an overlayed panel with the table.

    ResultMatrixOnQuoteLine

In the above examples, the table is calculated in a logic and given as an output to an Element. The type of the object is ResultMatrix.

Configuration

You need to setup:

  • Groovy code in logic’s element, which will return an object of type ResultMatrix.

  • (Optional) Set the Element’s Format Type to Matrix or Charts.

Simple ResultMatrix definition
// Create new ResultMatrix object with 2 columns
def resultMatrix = api.newMatrix("Customer Id", "Net Margin %")

// Add 3 data rows
resultMatrix.addRow([ "Customer Id" : "C1", "Net Margin %" : 0.104  ]) // ❶
resultMatrix.addRow([ "Customer Id" : "C2", "Net Margin %" : 0.044  ])
resultMatrix.addRow([ "Customer Id" : "C3", "Net Margin %" : 0.014  ])

return resultMatrix

Formatting

Column Formatting
matrix.setColumnFormat("Net Margin %", FieldFormatType.PERCENT)
Cell Data Formatting
def value = "C1"
def styledValue = matrix.styledCell(value, "#ff0000", "transparent", "bold")
resultMatrix.addRow([ "Customer Id" : styledValue, "Net Margin %" : 0.104  ])

Cell Content

Besides text and number, you can also display inside of the Cell the following:

  • Action Buttons

  • URL link

  • Image

Action Buttons

matrix.addRow([
    //link to a Price Grid of the given ID
    "Pricegrid" : matrix.linkToPriceGrid("Open Pricegrid", 2147483768, Filter.equal("currency","EUR")),

    // link to a Price List of the given ID
    "Pricelist" : matrix.linkToPriceList("Open Pricelist", 13970, null),

    // link to a Company Parameter of given ID
    "Company Parameter" : matrix.linkToPriceParameter("Open Company Parameter", 1586182204829828),

    // or a to custom page (result identical to the previous)
    "CustomerId" : matrix.linkCell("Customer Detail", "customersPage", "CD-00001"),

    // in-line actions
    "Revoke" : matrix.backEndAction("Revoke", "/pricelistmanager.revoke/14019",  //❶
                                    null, "OK", "Not OK"),
    "Download PDF" : matrix.downloadButton("Download", "/pricelistmanager.fetchpdf/14019", null),

    //actions grouped under one button
    "Actions" : matrix.cells("Actions",
         matrix.backEndAction("Revoke","/pricelistmanager.revoke/14019",        //❶
                                null,"OK","Not OK"),
         matrix.downloadButton("Download","/pricelistmanager.fetchpdf/14019",null)
    )

])

❶ This is a call to REST API, so you’re calling Pricefx using the outside API.Try to always use the Groovy API whenever possible, and such REST API calls only when necessary.

matrix.addRow([
    'Url' : '<a href="https://www.pricefx.com">link</a>',
])

Image

matrix.addRow([
    // or add a library images, such as Traffic, BlackTraffic or Arrow
    "Margin Status" : matrix.libraryImage("BlackTraffic", getTrafficColor(-0.2f)),

    // or add a general image
    "Image" : matrix.imageCell("/classic/images/grid/sampleimage.png"),
])

How to Get ResultMatrix from DM Query

A result of DM Query can quite easily be turned into a ResultMatrix and thus displayed on screen in Dashboard, Price List, Quote, etc.

def ctx = api.getDatamartContext()
def dm = ctx.getDatamart("Transactions")
def query = ctx.newQuery(dm, true)
query.select("CustomerId")
query.select("SUM(Sales)", "Revenue")
def queryResult = ctx.executeQuery(query)

/* The following line turns the DatamartQueryResult to Matrix2D and then to ResultMatrix which can be directly displayed on the screen */
return queryResult?.getData()?.toResultMatrix()

Triggering Events

When the ResultMatrix table is displayed in a Dashboard and the user clicks on its row, the click can generate an Event which can cause an Embedded dashboard to be refreshed.

For more information look up the topic Interactive Dashboards.

References

  • No labels