Class sap.ui.commons.TreeModule: sap/ui/commons/Tree

extends Control

Simple tree to display item in a hierarchical way

Deprecated API:Since version 1.38.

Constructor Summary
new sap.ui.commons.Tree(sId?, mSettings?)Constructor for a new Tree.
Event Summary
select(oControlEvent)Event is fired when a tree node is selected.
selectionChange(oControlEvent)fired when the selection of the tree has been changed
Events borrowed from class sap.ui.core.Control
Method Summary
sap.ui.commons.Tree.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.commons.Tree with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.commons.Tree.getMetadata()Returns a metadata object for class sap.ui.commons.Tree.
addNode(oNode)Adds some node to the aggregation nodes.
attachSelect(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the select event of this sap.ui.commons.Tree.
attachSelectionChange(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the selectionChange event of this sap.ui.commons.Tree.
bindNodes(oBindingInfo)Binds aggregation nodes to model data.
collapseAll()Collapses all nodes in the tree
destroyNodes()Destroys all the nodes in the aggregation nodes.
detachSelect(fnFunction, oListener)Detaches event handler fnFunction from the select event of this sap.ui.commons.Tree.
detachSelectionChange(fnFunction, oListener)Detaches event handler fnFunction from the selectionChange event of this sap.ui.commons.Tree.
expandAll()Expands all nodes in the tree
fireSelect(mArguments?)Fires event select to attached listeners.
fireSelectionChange(mArguments?)Fires event selectionChange to attached listeners.
getHeight()Gets current value of property height.
getMinWidth()Gets current value of property minWidth.
getNodeByContext(oContext)Returns the node with the given context, or null if no such node currently exists
getNodes()Gets content of aggregation nodes.
getSelectionMode()Gets current value of property selectionMode.
getShowHeader()Gets current value of property showHeader.
getShowHeaderIcons()Gets current value of property showHeaderIcons.
getShowHorizontalScrollbar()Gets current value of property showHorizontalScrollbar.
getTitle()Gets current value of property title.
getWidth()Gets current value of property width.
indexOfNode(oNode)Checks for the provided sap.ui.commons.TreeNode in the aggregation nodes.
insertNode(oNode, iIndex)Inserts a node into the aggregation nodes.
removeAllNodes()Removes all the controls from the aggregation nodes.
removeNode(vNode)Removes a node from the aggregation nodes.
setHeight(sHeight)Sets a new value for property height.
setMinWidth(sMinWidth)Sets a new value for property minWidth.
setSelectionMode(sSelectionMode)Sets a new value for property selectionMode.
setShowHeader(bShowHeader)Sets a new value for property showHeader.
setShowHeaderIcons(bShowHeaderIcons)Sets a new value for property showHeaderIcons.
setShowHorizontalScrollbar(bShowHorizontalScrollbar)Sets a new value for property showHorizontalScrollbar.
setTitle(sTitle)Sets a new value for property title.
setWidth(sWidth)Sets a new value for property width.
unbindNodes()Unbinds aggregation nodes from model data.
Constructor Detail
new sap.ui.commons.Tree(sId?, mSettings?)
Constructor for a new Tree.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject for a general description of the syntax of the settings object.

The supported settings are:

  • Properties
  • Aggregations
    • nodes : sap.ui.commons.TreeNode[] (default)
  • Events
    • select : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
    • selectionChange : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

In addition, all settings applicable to the base type sap.ui.core.Control can be used as well.

Parameters:
{string}sId? id for the new control, generated automatically if no id is given
{object}mSettings? initial settings for the new control
Deprecated:
Since version 1.38.
Event Detail
select(oControlEvent)
Event is fired when a tree node is selected.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{sap.ui.commons.TreeNode}oControlEvent.getParameters.node The node which has been selected.
{object}oControlEvent.getParameters.nodeContext The binding context of the selected node.
selectionChange(oControlEvent)
fired when the selection of the tree has been changed
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{sap.ui.commons.TreeNode[]}oControlEvent.getParameters.nodes The nodes which has been selected.
{object[]}oControlEvent.getParameters.nodeContexts The binding context of the selected nodes.
Method Detail
sap.ui.commons.Tree.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.commons.Tree 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.core.Control.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.commons.Tree.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.commons.Tree.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
addNode(oNode): sap.ui.commons.Tree
Adds some node to the aggregation nodes.
Parameters:
{sap.ui.commons.TreeNode}oNode the node to add; if empty, nothing is inserted
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
attachSelect(oData?, fnFunction, oListener?): sap.ui.commons.Tree
Attaches event handler fnFunction to the select event of this sap.ui.commons.Tree.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.commons.Tree itself.

Event is fired when a tree node is selected.

Parameters:
{object}oData? An application-specific payload object that will be passed to the event handler along with the event object when firing the event
{function}fnFunction The function to be called when the event occurs
{object}oListener? Context object to call the event handler with. Defaults to this sap.ui.commons.Tree itself
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
attachSelectionChange(oData?, fnFunction, oListener?): sap.ui.commons.Tree
Attaches event handler fnFunction to the selectionChange event of this sap.ui.commons.Tree.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.commons.Tree itself.

fired when the selection of the tree has been changed

Parameters:
{object}oData? An application-specific payload object that will be passed to the event handler along with the event object when firing the event
{function}fnFunction The function to be called when the event occurs
{object}oListener? Context object to call the event handler with. Defaults to this sap.ui.commons.Tree itself
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
bindNodes(oBindingInfo): sap.ui.commons.Tree
Binds aggregation nodes to model data.

See ManagedObject.bindAggregation for a detailed description of the possible properties of oBindingInfo.

Parameters:
{object}oBindingInfo The binding information
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
collapseAll(): void
Collapses all nodes in the tree
destroyNodes(): sap.ui.commons.Tree
Destroys all the nodes in the aggregation nodes.
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
detachSelect(fnFunction, oListener): sap.ui.commons.Tree
Detaches event handler fnFunction from the select event of this sap.ui.commons.Tree.

The passed function and listener object must match the ones used for event registration.

Parameters:
{function}fnFunction The function to be called, when the event occurs
{object}oListener Context object on which the given function had to be called
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
detachSelectionChange(fnFunction, oListener): sap.ui.commons.Tree
Detaches event handler fnFunction from the selectionChange event of this sap.ui.commons.Tree.

The passed function and listener object must match the ones used for event registration.

Parameters:
{function}fnFunction The function to be called, when the event occurs
{object}oListener Context object on which the given function had to be called
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
expandAll(): void
Expands all nodes in the tree
fireSelect(mArguments?): boolean
Fires event select to attached listeners.

Listeners may prevent the default action of this event by using the preventDefault-method on the event object.

Expects the following event parameters:

  • node of type sap.ui.commons.TreeNodeThe node which has been selected.
  • nodeContext of type objectThe binding context of the selected node.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{boolean} Whether or not to prevent the default action
fireSelectionChange(mArguments?): sap.ui.commons.Tree
Fires event selectionChange to attached listeners.

Expects the following event parameters:

  • nodes of type sap.ui.commons.TreeNode[]The nodes which has been selected.
  • nodeContexts of type object[]The binding context of the selected nodes.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
getHeight(): sap.ui.core.CSSSize
Gets current value of property height.

Tree height

Default value is auto.

Returns:
{sap.ui.core.CSSSize} Value of property height
getMinWidth(): sap.ui.core.CSSSize
Gets current value of property minWidth.

Minimal width for the Tree. Can be useful when, for example, the width is specified in percentage, to avoid the tree to become too narrow when container is resize

Returns:
{sap.ui.core.CSSSize} Value of property minWidth
getNodeByContext(oContext)
Returns the node with the given context, or null if no such node currently exists
Parameters:
{sap.ui.model.Context}oContext the context of the node to be retrieved
Since:
1.19
Gets content of aggregation nodes.

First level nodes

Returns:
{sap.ui.commons.TreeNode[]}
Gets current value of property selectionMode.

Selection mode of the Tree.

Default value is Legacy.

Returns:
{sap.ui.commons.TreeSelectionMode} Value of property selectionMode
getShowHeader(): boolean
Gets current value of property showHeader.

Tree Header is display. If false, the tree will be in a transparent mode

Default value is true.

Returns:
{boolean} Value of property showHeader
getShowHeaderIcons(): boolean
Gets current value of property showHeaderIcons.

Show Header icons (e.g. Expand/Collapse all). Only consider if showHeader is true

Default value is true.

Returns:
{boolean} Value of property showHeaderIcons
getShowHorizontalScrollbar(): boolean
Gets current value of property showHorizontalScrollbar.

Display horizontal scrollbar. If false, the overflow content will be hidden

Default value is false.

Returns:
{boolean} Value of property showHorizontalScrollbar
getTitle(): string
Gets current value of property title.

Tree title

Returns:
{string} Value of property title
getWidth(): sap.ui.core.CSSSize
Gets current value of property width.

Tree width

Default value is auto.

Returns:
{sap.ui.core.CSSSize} Value of property width
indexOfNode(oNode): int
Checks for the provided sap.ui.commons.TreeNode in the aggregation nodes. and returns its index if found or -1 otherwise.
Parameters:
{sap.ui.commons.TreeNode}oNode The node whose index is looked for
Returns:
{int} The index of the provided control in the aggregation if found, or -1 otherwise
insertNode(oNode, iIndex): sap.ui.commons.Tree
Inserts a node into the aggregation nodes.
Parameters:
{sap.ui.commons.TreeNode}oNode the node to insert; if empty, nothing is inserted
{int}iIndex the 0-based index the node should be inserted at; for a negative value of iIndex, the node is inserted at position 0; for a value greater than the current size of the aggregation, the node is inserted at the last position
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
removeAllNodes(): sap.ui.commons.TreeNode[]
Removes all the controls from the aggregation nodes.

Additionally, it unregisters them from the hosting UIArea.

Returns:
{sap.ui.commons.TreeNode[]} An array of the removed elements (might be empty)
removeNode(vNode): sap.ui.commons.TreeNode
Removes a node from the aggregation nodes.
Parameters:
{int|string|sap.ui.commons.TreeNode}vNode The nodeto remove or its index or id
Returns:
{sap.ui.commons.TreeNode} The removed node or null
setHeight(sHeight): sap.ui.commons.Tree
Sets a new value for property height.

Tree height

When called with a value of null or undefined, the default value of the property will be restored.

Default value is auto.

Parameters:
{sap.ui.core.CSSSize}sHeight New value for property height
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
setMinWidth(sMinWidth): sap.ui.commons.Tree
Sets a new value for property minWidth.

Minimal width for the Tree. Can be useful when, for example, the width is specified in percentage, to avoid the tree to become too narrow when container is resize

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
{sap.ui.core.CSSSize}sMinWidth New value for property minWidth
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
setSelectionMode(sSelectionMode): sap.ui.commons.Tree
Sets a new value for property selectionMode.

Selection mode of the Tree.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Legacy.

Parameters:
{sap.ui.commons.TreeSelectionMode}sSelectionMode New value for property selectionMode
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
setShowHeader(bShowHeader): sap.ui.commons.Tree
Sets a new value for property showHeader.

Tree Header is display. If false, the tree will be in a transparent mode

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

Parameters:
{boolean}bShowHeader New value for property showHeader
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
setShowHeaderIcons(bShowHeaderIcons): sap.ui.commons.Tree
Sets a new value for property showHeaderIcons.

Show Header icons (e.g. Expand/Collapse all). Only consider if showHeader is true

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

Parameters:
{boolean}bShowHeaderIcons New value for property showHeaderIcons
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
setShowHorizontalScrollbar(bShowHorizontalScrollbar): sap.ui.commons.Tree
Sets a new value for property showHorizontalScrollbar.

Display horizontal scrollbar. If false, the overflow content will be hidden

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

Parameters:
{boolean}bShowHorizontalScrollbar New value for property showHorizontalScrollbar
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
setTitle(sTitle): sap.ui.commons.Tree
Sets a new value for property title.

Tree title

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
{string}sTitle New value for property title
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
setWidth(sWidth): sap.ui.commons.Tree
Sets a new value for property width.

Tree width

When called with a value of null or undefined, the default value of the property will be restored.

Default value is auto.

Parameters:
{sap.ui.core.CSSSize}sWidth New value for property width
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining
unbindNodes(): sap.ui.commons.Tree
Unbinds aggregation nodes from model data.
Returns:
{sap.ui.commons.Tree} Reference to this in order to allow method chaining