Filter for the list binding.
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):
path
, operator
and one or two values (value1
, value2
), depending on the operator path
and a custom filter function test
filters
and a Boolean flag and
that specifies whether to combine the filters with an AND (true
) or an OR (false
) operator. 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. Client models filter case insensitive compared to the OData models which filter case sensitive by default. See particular model documentation for details.
The filter operators "Any" and "All" are only supported in V4 OData models. When creating a filter instance with these filter operators, the argument variable
only accepts a string identifier and condition
needs to be another filter instance.
new sap.ui.model.Filter(vFilterInfo, vOperator?, vValue1?, vValue2?)
Param | Type | Default Value | Description |
---|---|---|---|
vFilterInfo | object string sap.ui.model.Filter[] | Filter info object or a path or an array of filters |
|
path? | string | Binding path for this filter |
|
test? | function(any) : boolean | Function used for the client-side filtering of items. It should return a Boolean indicating whether the current item passes the filter. If no test function is given, a default test function is used, based on the given filter operator and the comparator function. |
|
comparator? | function(any,any) : number | Function used to compare two values for equality and order during client-side filtering. Two values are given as parameters. The function is expected to return:
|
|
operator? | sap.ui.model.FilterOperator | Operator used for the filter |
|
value1? | any | First value to use with the given filter operator |
|
value2? | any | Second value to use with the given filter operator, used only for the "BT" between and "NB" not between filter operators |
|
variable? | string | The variable name used in lambda operators ("Any" and "All") |
|
condition? | sap.ui.model.Filter | A filter instance which will be used as the condition for lambda operators ("Any" and "All") |
|
filters? | sap.ui.model.Filter[] | An array of filters on which the logical conjunction is applied |
|
and? | boolean | false | Indicates whether an "AND" logical conjunction is applied on the filters. If it's not set or set to |
caseSensitive? | boolean | Indicates whether a string value should be compared case sensitive or not. The handling of |
|
vOperator? | sap.ui.model.FilterOperator function(any) : boolean boolean | Either a filter operator or a custom filter function or a |
|
vValue1? | any | First value to use with the given filter operator |
|
vValue2? | any | Second value to use with the given filter operator, used only for the "BT" between and "NB" not between filter operators |
Method | Description |
---|---|
sap.ui.model.Filter.defaultComparator |
Compares two values This is the default comparator function used for client-side 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. |
sap.ui.model.Filter.extend |
Creates a new subclass of class sap.ui.model.Filter with name
|
getComparator |
Returns the comparator function as provided on construction of this filter, see sap.ui.model.Filter#constructor, parameter |
getCondition |
Returns the filter instance which is used as the condition for lambda operators, see sap.ui.model.Filter#constructor, parameter |
getFilters |
Returns the array of filters as specified on construction of this filter, see sap.ui.model.Filter#constructor, parameter |
sap.ui.model.Filter.getMetadata |
Returns a metadata object for class sap.ui.model.Filter. |
getOperator |
Returns the filter operator used for this filter, see sap.ui.model.Filter#constructor, parameter |
getPath |
Returns the binding path for this filter, see sap.ui.model.Filter#constructor, parameter |
getTest |
Returns the test function which is used to filter the items, see sap.ui.model.Filter#constructor, parameter |
getValue1 |
Returns the first value that is used with the given filter operator, see sap.ui.model.Filter#constructor, parameter |
getValue2 |
Returns the second value that is used with the given filter operator, see sap.ui.model.Filter#constructor, parameter |
getVariable |
Returns the variable name used in lambda operators, see sap.ui.model.Filter#constructor, parameter |
isAnd |
Indicates whether an "AND" logical conjunction is applied on the filters, see sap.ui.model.Filter#constructor, parameter |
isCaseSensitive |
Indicates whether a string value should be compared case sensitive, see sap.ui.model.Filter#constructor, parameter |
Compares two values
This is the default comparator function used for client-side 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.
Param | Type | DefaultValue | Description |
---|---|---|---|
a | any |
the first value to compare |
|
b | any |
the second value to compare |
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.
Param | Type | DefaultValue | Description |
---|---|---|---|
sClassName | string |
Name of the class being created |
|
oClassInfo | object |
Object literal with information about the class |
|
FNMetaImpl | function |
Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class |
Returns the comparator function as provided on construction of this filter, see sap.ui.model.Filter#constructor, parameter vFilterInfo.comparator
.
Returns the filter instance which is used as the condition for lambda operators, see sap.ui.model.Filter#constructor, parameter vFilterInfo.condition
.
Returns the array of filters as specified on construction of this filter, see sap.ui.model.Filter#constructor, parameter vFilterInfo.filters
Returns the filter operator used for this filter, see sap.ui.model.Filter#constructor, parameter vFilterInfo.operator
or vOperator
.
Returns the binding path for this filter, see sap.ui.model.Filter#constructor, parameter vFilterInfo
or vFilterInfo.path
.
Returns the test function which is used to filter the items, see sap.ui.model.Filter#constructor, parameter vFilterInfo.test
.
Returns the first value that is used with the given filter operator, see sap.ui.model.Filter#constructor, parameter vFilterInfo.value1
or vValue1
.
Returns the second value that is used with the given filter operator, see sap.ui.model.Filter#constructor, parameter vFilterInfo.value2
or vValue2
.
Returns the variable name used in lambda operators, see sap.ui.model.Filter#constructor, parameter vFilterInfo.variable
.
Indicates whether an "AND" logical conjunction is applied on the filters, see sap.ui.model.Filter#constructor, parameter vFilterInfo.and
.
Indicates whether a string value should be compared case sensitive, see sap.ui.model.Filter#constructor, parameter vFilterInfo.caseSensitive
.