Class sap.ui.model.odata.v2.ODataTreeBindingModule: sap/ui/model/odata/v2/ODataTreeBinding

extends TreeBinding

Tree binding implementation for odata models. To use the v2.ODataTreeBinding with an odata service, which exposes hierarchy annotations, please consult the "SAP Annotations for OData Version 2.0" Specification. The necessary property annotations, as well as accepted/default values are documented in the specification.

In addition to these hieararchy annotations, the ODataTreeBinding also supports (cyclic) references between entities based on navigation properties. To do this you have to specify the binding parameter "navigation". The pattern for this is as follows: { entitySetName: "navigationPropertyName" }. Example: { "Employees": "toColleagues" }

In OperationMode.Server, the filtering on the ODataTreeBinding is only supported with initial filters. However please be aware that this applies only to filters which do not obstruct the creation of a hierarchy. So filtering on a property (e.g. a "Customer") is fine, as long as the application can ensure, that the responses from the backend are enough to construct a tree hierarchy. Subsequent paging requests for sibiling and child nodes must also return responses since the filters will be sent with every request. Filtering with the filter() function is not supported for the OperationMode.Server.

With OperationMode.Client and OperationMode.Auto, the ODataTreeBinding also supports control filters. In these OperationModes, the filters and sorters will be applied clientside, same as for the v2.ODataListBinding. The OperationModes "Client" and "Auto" are only supported for trees which will be constructed based upon hierarchy annotations.

Constructor Summary
new sap.ui.model.odata.v2.ODataTreeBinding(oModel, sPath, oContext, aApplicationFilters?, mParameters?, aSorters?)
Method Summary
sap.ui.model.odata.v2.ODataTreeBinding.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.model.odata.v2.ODataTreeBinding with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.model.odata.v2.ODataTreeBinding.getMetadata()Returns a metadata object for class sap.ui.model.odata.v2.ODataTreeBinding.
filter(aFilters, sFilterType)Applies the given filters to the ODataTreeBinding.
getChildCount(oContext)Returns the number of child nodes
getDownloadUrl(sFormat)Get a download URL with the specified format considering the sort/filter/custom parameters.
getNodeContexts(oContext, iStartIndex, iLength, iThreshold)Returns the contexts of the child nodes for the given context.
getRootContexts(iStartIndex?, iLength?, iThreshold?)Returns root contexts for the tree.
getRootLevel()Returns the rootLevel
hasChildren(oContext)Returns if the node has child nodes.
initialize()Initialize binding.
refresh(bForceUpdate?, sGroupId?)Refreshes the binding, check whether the model data has been changed and fire change event if this is the case.
setRootLevel(iRootLevel)Sets the rootLevel The root level is the level of the topmost tree nodes, which will be used as an entry point for OData services.
sort(aSorters)Sorts the Tree according to the given Sorter(s).
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.model.odata.v2.ODataTreeBinding(oModel, sPath, oContext, aApplicationFilters?, mParameters?, aSorters?)
Parameters:
{sap.ui.model.Model}oModel
{string}sPath
{sap.ui.model.Context}oContext
{sap.ui.model.Filter[]}aApplicationFilters? predefined filter/s (can be either a filter or an array of filters). All initial filters, will be sent with every request. Filtering on the ODataTreeBinding is only supported with initial filters.
{object}mParameters? Parameter Object
{object}mParameters.treeAnnotationProperties? This parameter defines the mapping between data properties and the hierarchy used to visualize the tree, if not provided by the services metadata. For correct metadata annotation, please check the "SAP Annotations for OData Version 2.0" Specification.
{int}mParameters.treeAnnotationProperties.hierarchyLevelFor? Mapping to the property holding the level information,
{string}mParameters.treeAnnotationProperties.hierarchyNodeFor? Mapping to the property holding the hierarchy node id,
{string}mParameters.treeAnnotationProperties.hierarchyParentNodeFor? Mapping to the property holding the parent node id,
{string}mParameters.treeAnnotationProperties.hierarchyDrillStateFor? Mapping to the property holding the drill state for the node,
{object}mParameters.navigation? An map describing the navigation properties between entity sets, which should be used for constructing and paging the tree.
{int}mParameters.numberOfExpandedLevels? This property defines the number of levels, which will be expanded initially. Please be aware, that this property leads to multiple backend requests. Default value is 0.
{int}mParameters.rootLevel? The root level is the level of the topmost tree nodes, which will be used as an entry point for OData services. Conforming to the "SAP Annotations for OData Version 2.0" Specification, the root level must start at 0. Default value is thus 0.
{string}mParameters.batchGroupId? Deprecated - use groupId instead: sets the batch group id to be used for requests originating from this binding
{string}mParameters.groupId? sets the group id to be used for requests originating from this binding
{sap.ui.model.Sorter[]}aSorters? predefined sorter/s (can be either a sorter or an array of sorters)
{int}mParameters.threshold? a threshold, which will be used if the OperationMode is set to "Auto". In case of OperationMode.Auto, the binding tries to fetch (at least) as many entries as the threshold. Also see API documentation for sap.ui.model.OperationMode.Auto.
{boolean}mParameters.useServersideApplicationFilters? set this flag if $filter statements should be used for the $count/$inlinecount and data-retrieval in the OperationMode.Auto. Only use this if your backend supports prefiltering the tree and is capable of responding a complete tree hierarchy, including all inner nodes. To construct the hierarchy on the client, it is mandatory that all filter-matches include their complete parent chain up to the root level. OperationMode.Client will still request the complete collection without filters, since they will be applied clientside.
Method Detail
sap.ui.model.odata.v2.ODataTreeBinding.extend(sClassName, oClassInfo?, FNMetaImpl?): function
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.

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.odata.v2.ODataTreeBinding.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.model.odata.v2.ODataTreeBinding.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
filter(aFilters, sFilterType): sap.ui.model.odata.v2.ODataTreeBinding
Applies the given filters to the ODataTreeBinding. Please note that "Control" filters are not suported for OperationMode.Server, here only "Application" filters are allowed. Filters given via the constructor are always Application filters and will be send with every backend-request. Please see the constructor documentation for more information.

Since 1.34.0 complete clientside filtering is supported for OperationMode.Client and in OperationMode.Auto, in case the backend-count is lower than the threshold. In this case all control and application filters will be applied on the client. See also: sap.ui.model.odata.OperationMode.Auto, sap.ui.model.FilterType.

For the OperationMode.Client and OperationMode.Auto, you may also specify the "useServersideApplicationFilters" constructor binding parameter. If this is set, the Application filters will always be applied on the backend, and thus trigger an OData request. Please see the constructor documentation for more information.

Parameters:
{sap.ui.model.Filter[]|sap.ui.model.Filter}aFilters
{sap.ui.model.FilterType}sFilterType Type of the filter which should be adjusted, if it is not given, the standard behaviour FilterType.Client applies
Returns:
{sap.ui.model.odata.v2.ODataTreeBinding} returns this to facilitate method chaining
See:
sap.ui.model.TreeBinding.prototype.filter
getChildCount(oContext): int
Returns the number of child nodes
Parameters:
{Object}oContext the context element of the node
Returns:
{int} the number of children
getDownloadUrl(sFormat): string
Get a download URL with the specified format considering the sort/filter/custom parameters.
Parameters:
{string}sFormat Value for the $format Parameter
Since:
1.28
Returns:
{string} URL which can be used for downloading
getNodeContexts(oContext, iStartIndex, iLength, iThreshold): sap.ui.model.Context[]
Returns the contexts of the child nodes for the given context.
Parameters:
{sap.ui.model.Context}oContext the context for which the child nodes should be retrieved
{int}iStartIndex the start index of the requested contexts
{int}iLength the requested amount of contexts
{int}iThreshold
Returns:
{sap.ui.model.Context[]} the contexts array
getRootContexts(iStartIndex?, iLength?, iThreshold?): sap.ui.model.Context[]
Returns root contexts for the tree. You can specify the start index and the length for paging requests
Parameters:
{int}iStartIndex? the start index of the requested contexts
{int}iLength?, Default: 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.
{int}iThreshold? 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.
Returns:
{sap.ui.model.Context[]} an array containing the contexts for the entities returned by the backend, might be fewer than requested if the backend does not have enough data.
getRootLevel(): int
Returns the rootLevel
Returns:
{int}
hasChildren(oContext): boolean
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.
Parameters:
{sap.ui.model.Context}oContext the context element of the node
Returns:
{boolean} true if node has children
Initialize binding. Fires a change if data is already available ($expand) or a refresh. If metadata is not yet available, do nothing, method will be called again when metadata is loaded.
Returns:
{sap.ui.model.odata.v2.ODataTreeBinding} The binding instance
refresh(bForceUpdate?, sGroupId?)
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, please use the parameter bForceUpdate.
Parameters:
{boolean}bForceUpdate? Update the bound control even if no data has been changed
{string}sGroupId? The group Id for the refresh
setRootLevel(iRootLevel)
Sets the rootLevel The root level is the level of the topmost tree nodes, which 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. See the constructor for API documentation on this.
Parameters:
{int}iRootLevel
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.
Parameters:
{sap.ui.model.Sorter[]|sap.ui.model.Sorter}aSorters the Sorter or an Array of sap.ui.model.Sorter instances
Returns:
{sap.ui.model.odata.v2.ODataTreeBinding} returns this to facilitate method chaining