Sorts row with a custom javascript expression. More...
Import Statement: | import Felgo 4.0 |
Since: | Felgo 2.18.1 |
Inherits: |
An ExpressionSorter is a Sorter allowing to implement custom sorting based on a javascript expression.
enabled : bool |
This property holds whether the sorter is enabled. A disabled sorter will not change the order of the rows.
By default, sorters are enabled.
expression : expression |
An expression to implement custom sorting. It must evaluate to a bool. It has the same syntax has a Property Binding, except that it will be
evaluated for each of the source model's rows. Model data is accessible for both rows with the modelLeft
, and modelRight
properties:
sorters: ExpressionSorter { expression: { return modelLeft.someRole < modelRight.someRole; } }
The index
of the row is also available through modelLeft
and modelRight
.
The expression should return true
if the value of the left item is less than the value of the right item, otherwise returns false.
This expression is reevaluated for a row every time its model data changes. When an external property (not index*
or in model*
) the expression depends on changes, the expression is reevaluated for
every row of the source model. To capture the properties the expression depends on, the expression is first executed with invalid data and each property access is detected by the QML engine. This means that if a property is
not accessed because of a conditional, it won't be captured and the expression won't be reevaluted when this property changes.
A workaround to this problem is to access all the properties the expressions depends unconditionally at the beggining of the expression.
sortOrder : Qt::SortOrder |
This property holds the sort order of this sorter.
Constant | Description |
---|---|
Qt.AscendingOrder |
The items are sorted ascending e.g. starts with 'AAA' ends with 'ZZZ' in Latin-1 locales |
Qt.DescendingOrder |
The items are sorted descending e.g. starts with 'ZZZ' ends with 'AAA' in Latin-1 locales |
By default, sorting is in ascending order.
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: