Show TOC

FilteringLocate this document in the navigation structure

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. 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
"models" : {
    "" : {
        "dataSource" : "default",
        "settings" : {
            "operationMode" : "Server",
            "synchronizationMode" : "None"
        }
    }
}

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

<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, or an array thereof. For an array, the filters are combined with a logical OR. You can set the initial value for the dynamic filter in ODataModel.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 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

<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',
                value : '0000',
            }
        }">

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