class sap.ui.model.odata.v2.ODataTreeBinding

Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/ui/model/odata/v2/ODataTreeBinding
Application Component: CA-UI5-COR

Tree binding implementation for the sap.ui.model.odata.v2.ODataModel. Use sap.ui.model.odata.v2.ODataModel#bindTree for creating an instance.


Constructor


Methods Overview

Method Description
expandNodeToLevel

Expand a nodes subtree to a given level.

This API is only supported in OperationMode.Server and if the OData service implements the full specification of the "hierarchy-node-for" annotation.

sap.ui.model.odata.v2.ODataTreeBinding.extend

Creates a new subclass of class sap.ui.model.odata.v2.ODataTreeBinding 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.model.TreeBinding.extend.

filter

Applies the given filters to the ODataTreeBinding.

Please note that filters of type FilterType.Control are not supported for OperationMode.Server, here only filters of type FilterType.Application are allowed. Filters given via sap.ui.model.odata.v2.ODataModel#bindTree are always of type Application and will be sent with every back-end request. For more information, see sap.ui.model.odata.v2.ODataModel#bindTree.

Since 1.34.0, complete client-side filtering is supported for OperationMode.Client and also in OperationMode.Auto if the back-end count is lower than the threshold. In this case, all types of filters will be applied on the client. See also: sap.ui.model.odata.OperationMode.Auto and sap.ui.model.FilterType.

For the OperationMode.Client and OperationMode.Auto, you may also specify the useServersideApplicationFilters binding parameter when creating an instance. If it is set, the filters of type Application will always be applied on the back end and trigger an OData request. For more information, see sap.ui.model.odata.v2.ODataModel#bindTree.

References:

  • sap.ui.model.TreeBinding.prototype.filter

getChildCount

Returns the number of child nodes. This function is not available when the annotation "hierarchy-node-descendant-count-for" is exposed on the service.

getDownloadUrl

Get a download URL with the specified format considering the sort/filter/custom parameters.

sap.ui.model.odata.v2.ODataTreeBinding.getMetadata

Returns a metadata object for class sap.ui.model.odata.v2.ODataTreeBinding.

getNodeContexts

Returns the contexts of the child nodes for the given context. This function is not available when the annotation "hierarchy-node-descendant-count-for" is exposed on the service.

getRootContexts

Returns root contexts for the tree. You can specify the start index and the length for paging requests. This function is not available when the annotation "hierarchy-node-descendant-count-for" is exposed on the service.

getRootLevel

Returns the rootLevel

getTreeAnnotation

Returns the value of a given hierarchy annotation.

hasChildren

Returns if the node has child nodes. If the ODataTreeBinding is running with hierarchy annotations, a context with the property values "expanded" or "collapsed" for the drilldown state property, returns true. Entities with drilldown state "leaf" return false.

This function is not available when the annotation "hierarchy-node-descendant-count-for" is exposed on the service.

initialize

Initializes the binding. Fires a refresh event once initialization is completed in case the binding is resolved, or immediately in case it is unresolved.

refresh

Refreshes the binding, check whether the model data has been changed and fire change event if this is the case. For server side models this should refetch the data from the server. To update a control, even if no data has been changed, e.g. to reset a control after failed validation, use the parameter bForceUpdate.

setRootLevel

Sets the rootLevel. The root level is the level of the topmost tree nodes that will be used as an entry point for OData services. This is only possible (and necessary) for OData services implementing the hierarchy annotation specification, or when providing the annotation information locally as a binding parameter. For more information, see sap.ui.model.odata.v2.ODataModel#bindTree.

sort

Sorts the Tree according to the given Sorter(s). In OperationMode.Client or OperationMode.Auto (if the given threshold is satisfied), the sorters are applied locally on the client.

expandNodeToLevel

Expand a nodes subtree to a given level.

This API is only supported in OperationMode.Server and if the OData service implements the full specification of the "hierarchy-node-for" annotation.

Param Type DefaultValue Description
iIndex int

Absolute row index

iLevel int

Level to which the data should be expanded

bSuppressChange boolean

If set to true, no change event will be fired

sap.ui.model.odata.v2.ODataTreeBinding.extend

Creates a new subclass of class sap.ui.model.odata.v2.ODataTreeBinding 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.model.TreeBinding.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

filter

Applies the given filters to the ODataTreeBinding.

Please note that filters of type FilterType.Control are not supported for OperationMode.Server, here only filters of type FilterType.Application are allowed. Filters given via sap.ui.model.odata.v2.ODataModel#bindTree are always of type Application and will be sent with every back-end request. For more information, see sap.ui.model.odata.v2.ODataModel#bindTree.

Since 1.34.0, complete client-side filtering is supported for OperationMode.Client and also in OperationMode.Auto if the back-end count is lower than the threshold. In this case, all types of filters will be applied on the client. See also: sap.ui.model.odata.OperationMode.Auto and sap.ui.model.FilterType.

For the OperationMode.Client and OperationMode.Auto, you may also specify the useServersideApplicationFilters binding parameter when creating an instance. If it is set, the filters of type Application will always be applied on the back end and trigger an OData request. For more information, see sap.ui.model.odata.v2.ODataModel#bindTree.

References:

Param Type DefaultValue Description
aFilters sap.ui.model.Filter[] sap.ui.model.Filter

Filter or array of filters to apply

sFilterType sap.ui.model.FilterType

Type of the filter which should be adjusted. If it is not given, the type FilterType.Control is assumed

getChildCount

Returns the number of child nodes. This function is not available when the annotation "hierarchy-node-descendant-count-for" is exposed on the service.

Param Type DefaultValue Description
oContext Object

the context element of the node

getDownloadUrl

Get a download URL with the specified format considering the sort/filter/custom parameters.

Param Type DefaultValue Description
sFormat string

Value for the $format Parameter

sap.ui.model.odata.v2.ODataTreeBinding.getMetadata

Returns a metadata object for class sap.ui.model.odata.v2.ODataTreeBinding.

getNodeContexts

Returns the contexts of the child nodes for the given context. This function is not available when the annotation "hierarchy-node-descendant-count-for" is exposed on the service.

Param Type DefaultValue Description
oContext sap.ui.model.Context

The context for which the child nodes should be retrieved

iStartIndex int

The start index of the requested contexts

iLength int

The requested amount of contexts

iThreshold int 0

The maximum number of contexts to read before and after the given range; with this, controls can prefetch data that is likely to be needed soon, e.g. when scrolling down in a table.

getRootContexts

Returns root contexts for the tree. You can specify the start index and the length for paging requests. This function is not available when the annotation "hierarchy-node-descendant-count-for" is exposed on the service.

Param Type DefaultValue Description
iStartIndex int 0

The start index of the requested contexts

iLength int v2.ODataModel.sizeLimit

The requested amount of contexts. If none given, the default value is the size limit of the underlying sap.ui.model.odata.v2.ODataModel instance.

iThreshold int 0

The number of entities which should be retrieved in addition to the given length. A higher threshold reduces the number of backend requests, yet these request blow up in size, since more data is loaded.

getRootLevel

Returns the rootLevel

getTreeAnnotation

Returns the value of a given hierarchy annotation.

Param Type DefaultValue Description
sAttributeName string

The name of the hierarchy annotation

hasChildren

Returns if the node has child nodes. If the ODataTreeBinding is running with hierarchy annotations, a context with the property values "expanded" or "collapsed" for the drilldown state property, returns true. Entities with drilldown state "leaf" return false.

This function is not available when the annotation "hierarchy-node-descendant-count-for" is exposed on the service.

Param Type DefaultValue Description
oContext sap.ui.model.Context

the context element of the node

initialize

Initializes the binding. Fires a refresh event once initialization is completed in case the binding is resolved, or immediately in case it is unresolved.

refresh

Refreshes the binding, check whether the model data has been changed and fire change event if this is the case. For server side models this should refetch the data from the server. To update a control, even if no data has been changed, e.g. to reset a control after failed validation, use the parameter bForceUpdate.

Param Type DefaultValue Description
bForceUpdate boolean

Update the bound control even if no data has been changed

sGroupId string

The group Id for the refresh

setRootLevel

Sets the rootLevel. The root level is the level of the topmost tree nodes that will be used as an entry point for OData services. This is only possible (and necessary) for OData services implementing the hierarchy annotation specification, or when providing the annotation information locally as a binding parameter. For more information, see sap.ui.model.odata.v2.ODataModel#bindTree.

Param Type DefaultValue Description
iRootLevel int

sort

Sorts the Tree according to the given Sorter(s). In OperationMode.Client or OperationMode.Auto (if the given threshold is satisfied), the sorters are applied locally on the client.

Param Type DefaultValue Description
aSorters sap.ui.model.Sorter[] sap.ui.model.Sorter

the Sorter or an Array of sap.ui.model.Sorter instances