Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example

Assigns any data to the totalRow property within the ResultMatrix. It uses the same format as a standard ResultMatrix row, and you can also use a styled cell with styledCell(). This enables you to add, for example, SUM calculations into this row.

Info

Note: Multiple calls of withTotalRow(Object) will override the previously set totalRow data.

Code Block
languagegroovy
def matrix = api.newMatrix("MaterialNumber", "ShipToNumber", "SpecialPrice", "ListPrice", "SuplementalPrice", "SuplementalRate")

// Set column formats
matrix.setColumnFormat("MaterialNumber", FieldFormatType.NUMERIC)
matrix.setColumnFormat("ShipToNumber", FieldFormatType.NUMERIC)
matrix.setColumnFormat("SpecialPrice", FieldFormatType.MONEY_EUR)
matrix.setColumnFormat("ListPrice", FieldFormatType.MONEY_EUR)
matrix.setColumnFormat("SuplementalPrice", FieldFormatType.MONEY_EUR)
matrix.setColumnFormat("SuplementalRate", FieldFormatType.MONEY_EUR)
matrix.setColumnFormat("totalRow", FieldFormatType.NUMERIC)

// Allow users to filter values
matrix.setEnableClientFilter(true)
matrix.withTotalRow(50)

def totalRow = matrix.getTotalRow()
// Iterate 50 times to add rows
for (int i = 0; i < 50; i++) {
    // Add data row values
    matrix.addRow([
            "MaterialNumber"  : "2100616",
            "ShipToNumber"    : "2003248",
            "SpecialPrice"    : 2.65,
            "ListPrice"       : null,
            "SuplementalPrice": 1.99,
            "SuplementalRate" : 0.66,
            // "totalRow": totalRow
    ])
}

matrix.withTotalRow([
        "MaterialNumber"  : "2100616",
        "ShipToNumber"    : "2003248",
        "SpecialPrice"    : 2.65,
        "ListPrice"       : "253",
        "SuplementalPrice": 1.99,
        "SuplementalRate" : "0.66",
        //"totalRow": totalRow,
        "Percent"         : "1337"
])

matrix.withTotalRow([
        "MaterialNumber"  : matrix.styledCell("2100616", null, null, null, "left"),
        "ShipToNumber"    : matrix.styledCell("2003248", null, null, null, "right"),
        "SpecialPrice"    : matrix.styledCell(2.65, null, null, null, "left"),
        "ListPrice"       : matrix.styledCell(null, null, null, null, "left"),
        "SuplementalPrice": matrix.styledCell(1.99, null, null, null, "right"),
        "SuplementalRate" : matrix.styledCell("0.66", null, null, null, "left"),
        "totalRow"        : matrix.styledCell(totalRow, null, null, null, "left"),
        "Percent"         : matrix.styledCell("1286", null, null, null, "left")
])