Class sap.ui.model.FilterModule: sap/ui/model/Filter

extends Object

Filter for the list binding.

Constructor Summary
new sap.ui.model.Filter(vFilterInfo, vOperator?, oValue1?, oValue2?)Constructor for Filter.
Method Summary
sap.ui.model.Filter.defaultComparator(a, b)Compares two values

This is the default comparator function used for clientside filtering, if no custom comparator is given in the constructor.

sap.ui.model.Filter.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.model.Filter with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.model.Filter.getMetadata()Returns a metadata object for class sap.ui.model.Filter.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.model.Filter(vFilterInfo, vOperator?, oValue1?, oValue2?)
Constructor for Filter.

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 function test
  • An array of other filters named filters and a Boolean flag and that specifies whether to combine the filters with an AND (true) or an OR (false) operator.
An error will be logged to the console if an invalid combination of parameters is provided. Please note that a model implementation may not support a custom filter function, e.g. if the model does not perform client side filtering. It also depends on the model implementation if the filtering is case sensitive or not. See particular model documentation for details.
Parameters:
{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);

Method Detail
sap.ui.model.Filter.defaultComparator(a, b): int
Compares two values

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.

Parameters:
{any}a the first value to compare
{any}b the second value to compare
Returns:
{int} -1, 0, 1 or NaN depending on the compare result
sap.ui.model.Filter.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.model.Filter with name 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.

Parameters:
{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
Returns:
{function} Created class / constructor function
sap.ui.model.Filter.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.model.Filter.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class