FunctionAggregator QML Type

Aggregator calculating value using provided function. More...

Import Statement: import QtModelsToolkit .
Inherits:

SingleRoleAggregator

Properties

Detailed Description

In the following example symbolsAggregator provides list of symbols ["SNT", "ETH", "ZRX"]. The second instance symbolsAggregator computes maximum value of role balance (24).

ListModel {
    id: sourceModel

    ListElement {
        symbol: "SNT"
        balance: "4"
    }
    ListElement {
        symbol: "ETH"
        balance: "14"
    }
    ListElement {
        symbol: "ZRX"
        balance: "24"
    }
}

FunctionAggregator {
    id: symbolsAggregator

    model: sourceModel
    initialValue: []
    roleName: "symbol"

    aggregateFunction: (aggr, value) => [...aggr, value]
}

FunctionAggregator {
    id: maxBalanceAggregator

    model: sourceModel
    initialValue: "0"
    roleName: "balance"

    aggregateFunction: (aggr, value) => Math.max(aggr, value)
}

Property Documentation

aggregateFunction : any

Initial value used to compute aggregation.


initialValue : any

Initial value used to compute aggregation.


model : any

The source model used for aggregation.


roleName : any

Name of the role used for aggregation.


value : any

The value computed from the model.