Class sap.ui.model.FilterModule: sap/ui/model/Filter
Filter for the list binding.
This is the default comparator function used for clientside filtering, if no custom comparator is given in the constructor.
sClassName
and enriches it with the information contained in oClassInfo
.You either pass a single object literal with the filter parameters or use the individual constructor arguments. No matter which variant is used, only certain combinations of parameters are supported (the following list uses the names from the object literal):
- A
path
,operator
and one or two values (value1
,value2
), depending on the operator - A
path
and a custom filter functiontest
- An array of other filters named
filters
and a Boolean flagand
that specifies whether to combine the filters with an AND (true
) or an OR (false
) operator.
{object|string|sap.ui.model.Filter[]} | vFilterInfo | Filter info object or a path or an array of filters |
{string} | vFilterInfo.path | Binding path for this filter |
{function} | vFilterInfo.test | Function which is used to filter the items and which should return a Boolean value to indicate whether the current item passes the filter |
{function} | vFilterInfo.comparator | Function which is used to compare two values, this is used for processing of equal, less than and greater than operators |
{sap.ui.model.FilterOperator} | vFilterInfo.operator | Operator used for the filter |
{object} | vFilterInfo.value1 | First value to use with the given filter operator |
{object} | vFilterInfo.value2? | Second value to use with the filter operator (only for some operators) |
{sap.ui.model.Filter[]} | vFilterInfo.filters | Array of filters on which logical conjunction is applied |
{boolean} | vFilterInfo.and | Indicates whether an "AND" logical conjunction is applied on the filters. If it's set to false , an "OR" conjunction is applied |
{sap.ui.model.FilterOperator|function|boolean} | vOperator? | Either a filter operator or a custom filter function or a Boolean flag that defines how to combine multiple filters |
{any} | oValue1? | First value to use with the given filter operator |
{any} | oValue2? | Second value to use with the given filter operator (only for some operators) |
Using an object with a path, an operator and one or two values
new sap.ui.model.Filter({ path: "...", operator: "...", value1: "...", value2: "..." })
Using a path and a custom filter function:
new sap.ui.model.Filter({ path: "...", test: function(oValue) { } })
Combining a list of filters either with AND or OR
new sap.ui.model.Filter({ filters: [...], and: true|false })
Same as above, but using individual constructor arguments
new sap.ui.model.Filter(sPath, sOperator, oValue1, oValue2); OR new sap.ui.model.Filter(sPath, fnTest); OR new sap.ui.model.Filter(aFilters, bAnd);
This is the default comparator function used for clientside filtering, if no custom comparator is given in the constructor. It does compare just by using equal/less than/greater than with automatic type casting, except for null values, which are neither less or greater, and string values where localeCompare is used.
The comparator method returns -1, 0, 1 for comparable values and NaN for non-comparable values.
{any} | a | the first value to compare |
{any} | b | the second value to compare |
{int} | -1, 0, 1 or NaN depending on the compare result |
sClassName
and enriches it with the information contained in oClassInfo
. oClassInfo
might contain the same kind of information as described in sap.ui.base.Object.extend.
{string} | sClassName | Name of the class being created |
{object} | oClassInfo? | Object literal with information about the class |
{function} | FNMetaImpl? | Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata |
{function} | Created class / constructor function |
{sap.ui.base.Metadata} | Metadata object describing this class |