Skip to content

Commit

Permalink
OpenUI5 Documentation Update 19.10.2024
Browse files Browse the repository at this point in the history
  • Loading branch information
openui5bot committed Oct 19, 2024
1 parent 093fb7b commit 09598a9
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/0index.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ OpenUI5 Version for the OpenUI5 Demo Kit
- [Data Reuse](Data_Reuse_648e360.md)
- [Binding Events](Binding_Events_1a010d3.md)
- [Filtering](Filtering_5338bd1.md)
- [Selection](Selection_ec55312.md)
- [Sorting](Sorting_d2ce3f5.md)
- [Value Lists](Value_Lists_ab267a6.md)
- [OData Operations](OData_Operations_b54f789.md)
Expand Down
2 changes: 2 additions & 0 deletions docs/OData_V4_Model_5de13cf.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Bindings connect OpenUI5 view elements to model data, allowing changes in the mo
The OData V4 model supports certain events intended for applications, and others that are to be used for controls, as outlined in this section.
- **[Filtering](Filtering_5338bd1.md "The OData V4 Model supports server side filtering on lists.")**
The OData V4 Model supports server side filtering on lists.
- **[Selection](Selection_ec55312.md "The OData V4 Model supports server side filtering on lists.")**
The OData V4 Model supports server side filtering on lists.
- **[Sorting](Sorting_d2ce3f5.md "The OData V4 model supports server side sorting on lists.")**
The OData V4 model supports server side sorting on lists.
- **[Value Lists](Value_Lists_ab267a6.md "The OData V4 model supports the access to value list metadata and data.")**
Expand Down
169 changes: 169 additions & 0 deletions docs/Selection_ec55312.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<!-- loioec55312f796f45e8883810af3b68b46c -->

| loio |
| -----|
| ec55312f796f45e8883810af3b68b46c |

<div id="loio">

view on: [demo kit nightly build](https://sdk.openui5.org/nightly/#/topic/ec55312f796f45e8883810af3b68b46c) | [demo kit latest release](https://sdk.openui5.org/topic/ec55312f796f45e8883810af3b68b46c)</div>

## Selection

The OData V4 Model supports server side filtering on lists.

To use server side filtering, set the operation mode to [`sap.ui.model.odata.OperationMode.Server`](https://sdk.openui5.org/api/sap.ui.model.odata.OperationMode/properties). This can be done as follows:

- For a single `ODataListBinding` instance, set the binding parameter `$$operationMode`

- For all list bindings of the model, set the model parameter `operationMode`.


**Example: Operation mode set in `manifest.json` for the model**

```js

"models" : {
"" : {
"dataSource" : "default",
"settings" : {
"operationMode" : "Server",
"synchronizationMode" : "None"
}
}
}
```

**Example: Operation mode set as binding parameter for a specific list binding**

```js

<Table growing="true" growingThreshold="5" id="Equipments"
items="{
path : '/Equipments',
parameters : {
$$operationMode : 'Server',
$filter : 'Category eq \'Electronics\'',
$select : 'Category,EmployeeId,ID,Name'
}
}">
```

The `ODataListBinding` allows to set static and dynamic filters:

- To set a static filter, use the `$filter` system query option in the binding parameters. The static filter value is sent with every data service request for the binding; you may specify any filter value allowed in OData V4. The static filter cannot be overwritten for an existing binding.

- The dynamic filter is an instance of [sap.ui.model.Filter](https://sdk.openui5.org/api/sap.ui.model.Filter) , or an array thereof. For an array, the filters are combined with a logical AND. You can set the initial value for the dynamic filter in [ODataModel\#bindList](https://sdk.openui5.org/api/ODataModel%23methods/bindList) or declaratively in an XML view with the `filters` property in an aggregation's binding information. To set the dynamic filter, use the [ODataListBinding\#filter](https://sdk.openui5.org/api/ODataListBinding%23methods/filter) method. This filter overwrites the initial value specified on binding construction.


The `ODataListBinding` combines the dynamic filter and static filter with a logical AND.

**Examle: Dynamic and static filters**

```js

<Table growing="true" growingThreshold="5" id="Equipments"
items="{
path : '/Equipments',
parameters : {
$$operationMode : 'Server',
$filter : 'Category eq \'Electronics\'', <-- static filter
$select : 'Category,EmployeeId,ID,Name'
},
filters : { <-- dynamic filter initial value
path : 'EmployeeId',
operator : 'GE',
value1 : '0000'
}
}">
```

The example above filters the `Equipments` entity set by `Category` \(static filter\) and `EmployeeId` \(dynamic filter, initial value\).

***

<a name="loioec55312f796f45e8883810af3b68b46c__section_mqn_jkk_b1b"/>

### Filtering with Any and All

The OData V4 model also supports the Lambda Operators `any` and `all` as defined in section 5.1.1.10 of the [OData Version 4.0. Part 2: URL Conventions](http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions-complete.html#_Toc453752358) specification. They are represented by [sap.ui.model.Filter](https://sdk.openui5.org/api/sap.ui.model.Filter) objects with filter operators [sap.ui.model.FilterOperator.Any](https://sdk.openui5.org/api/sap.ui.model.FilterOperator/properties) and [sap.ui.model.FilterOperator.All](https://sdk.openui5.org/api/sap.ui.model.FilterOperator/properties).

Example:

```
sap.ui.model.Filter({
// the path of the collection for which the condition needs to be evaluated
path : "TEAM_2_EMPLOYEES",
// either sap.ui.model.FilterOperator.Any or sap.ui.model.FilterOperator.All
operator : sap.ui.model.FilterOperator.Any,
// any OData identifier which is a variable for the current element of the collection referenced by path
variable : "employee",
// the filter condition; the path of the nested filter contains the variable as prefix to reference current element of the collection
condition : new sap.ui.model.Filter("employee/AGE", sap.ui.model.FilterOperator.GT, 42)
})
```

The path of the filter object is the path of the collection for which the boolean condition needs to be evaluated. The variable can be any OData identifier and it needs to be part of the path of a nested filter condition.

***

#### Filter Operator any

The filter operator Any applies the `boolean` filter condition to each member of the collection referenced by `path`. If the condition is true for **at least one** member of the collection, the any-filter matches. The filter with the Any operator without a filter condition matches only if the collection referenced by path is not empty.

Example 1: Get all teams that have at least one employee who is older than 42

```
oTeamsBinding.filter(
new sap.ui.model.Filter({
path : "TEAM_2_EMPLOYEES",
operator : sap.ui.model.FilterOperator.Any,
variable : "employee",
condition : new sap.ui.model.Filter("employee/AGE", sap.ui.model.FilterOperator.GT, 42)
})
);
```

The resulting request would be: **`http://host/service/TEAMS?$filter=TEAM_2_EMPLOYEES/any(employee:employee/AGE gt 42)`**

Example 2: Get all teams that have at least one employee assigned

```
oTeamsBinding.filter(
new sap.ui.model.Filter({
path : "TEAM_2_EMPLOYEES",
operator : sap.ui.model.FilterOperator.Any
})
);
```

The resulting request would be: **`http://host/service/TEAMS?$filter=TEAM_2_EMPLOYEES/any()`**

***

#### Filter Operator all

The filter operator All applies the `boolean` filter condition to each member of the collection referenced by `path`. If the condition is true for **all** members of the collection, the all-filter matches.

Example: Get all teams for which all employees are older than 42.

```
oOrdersListBinding.filter(
new sap.ui.model.Filter({
path : "TEAM_2_EMPLOYEES",
operator : sap.ui.model.FilterOperator.All,
variable : "employee",
condition : new sap.ui.model.Filter("employee/AGE", sap.ui.model.FilterOperator.GT, 42)
})
);
```

The resulting request would be: **`http://host/service/TEAMS?$filter=TEAM_2_EMPLOYEES/all(employee:employee/AGE gt 42)`**

**Related Information**


[sap.ui.model.odata.OperationMode.Server](https://sdk.openui5.org/api/sap.ui.model.odata.OperationMode/properties)

3 changes: 3 additions & 0 deletions docs/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,9 @@
"Filtering": {
"link": "Filtering_5338bd1.md"
},
"Selection": {
"link": "Selection_ec55312.md"
},
"Sorting": {
"link": "Sorting_d2ce3f5.md"
},
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ OpenUI5 Version for the OpenUI5 Demo Kit
- [Data Reuse](Data_Reuse_648e360.md)
- [Binding Events](Binding_Events_1a010d3.md)
- [Filtering](Filtering_5338bd1.md)
- [Selection](Selection_ec55312.md)
- [Sorting](Sorting_d2ce3f5.md)
- [Value Lists](Value_Lists_ab267a6.md)
- [OData Operations](OData_Operations_b54f789.md)
Expand Down
1 change: 1 addition & 0 deletions docs/sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@
- [Data Reuse](Data_Reuse_648e360.md)
- [Binding Events](Binding_Events_1a010d3.md)
- [Filtering](Filtering_5338bd1.md)
- [Selection](Selection_ec55312.md)
- [Sorting](Sorting_d2ce3f5.md)
- [Value Lists](Value_Lists_ab267a6.md)
- [OData Operations](OData_Operations_b54f789.md)
Expand Down

0 comments on commit 09598a9

Please sign in to comment.