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(mParameters?)Fires event select to attached listeners.
fireSelectionChange(mParameters?)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:
stringsId?id for the new control, generated automatically if no id is given
objectmSettings?initial settings for the new control
Event Detail
select(oControlEvent)
Event is fired when a tree node is selected.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
sap.ui.commons.TreeNodeoControlEvent.getParameters.nodeThe node which has been selected.
objectoControlEvent.getParameters.nodeContextThe binding context of the selected node.
selectionChange(oControlEvent)
fired when the selection of the tree has been changed
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
sap.ui.commons.TreeNode[]oControlEvent.getParameters.nodesThe nodes which has been selected.
object[]oControlEvent.getParameters.nodeContextsThe 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:
stringsClassNameName of the class being created
objectoClassInfo?Object literal with information about the class
functionFNMetaImpl?Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
functionCreated 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.MetadataMetadata object describing this class
addNode(oNode): sap.ui.commons.Tree
Adds some node to the aggregation nodes.
Parameters:
sap.ui.commons.TreeNodeoNodethe node to add; if empty, nothing is inserted
Returns:
sap.ui.commons.TreeReference 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:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.ui.commons.Tree itself
Returns:
sap.ui.commons.TreeReference 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:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.ui.commons.Tree itself
Returns:
sap.ui.commons.TreeReference 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:
objectoBindingInfoThe binding information
Returns:
sap.ui.commons.TreeReference 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.TreeReference 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:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.ui.commons.TreeReference 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:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.ui.commons.TreeReference to this in order to allow method chaining
expandAll(): void
Expands all nodes in the tree
fireSelect(mParameters?): 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.

Parameters:
objectmParameters?Parameters to pass along with the event
sap.ui.commons.TreeNodemParameters.node?The node which has been selected.
objectmParameters.nodeContext?The binding context of the selected node.
Returns:
booleanWhether or not to prevent the default action
fireSelectionChange(mParameters?): sap.ui.commons.Tree
Fires event selectionChange to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
sap.ui.commons.TreeNode[]mParameters.nodes?The nodes which has been selected.
object[]mParameters.nodeContexts?The binding context of the selected nodes.
Returns:
sap.ui.commons.TreeReference 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.CSSSizeValue 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.CSSSizeValue of property minWidth
getNodeByContext(oContext)
Returns the node with the given context, or null if no such node currently exists
Parameters:
sap.ui.model.ContextoContextthe 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.TreeSelectionModeValue 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:
booleanValue 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:
booleanValue 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:
booleanValue of property showHorizontalScrollbar
getTitle(): string

Gets current value of property title.

Tree title

Returns:
stringValue of property title
getWidth(): sap.ui.core.CSSSize

Gets current value of property width.

Tree width

Default value is auto.

Returns:
sap.ui.core.CSSSizeValue 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.TreeNodeoNodeThe node whose index is looked for
Returns:
intThe 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.TreeNodeoNodethe node to insert; if empty, nothing is inserted
intiIndexthe 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.TreeReference 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.TreeNodevNodeThe node to remove or its index or id
Returns:
sap.ui.commons.TreeNodeThe 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.CSSSizesHeightNew value for property height
Returns:
sap.ui.commons.TreeReference 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.CSSSizesMinWidthNew value for property minWidth
Returns:
sap.ui.commons.TreeReference 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.TreeSelectionModesSelectionModeNew value for property selectionMode
Returns:
sap.ui.commons.TreeReference 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:
booleanbShowHeaderNew value for property showHeader
Returns:
sap.ui.commons.TreeReference 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:
booleanbShowHeaderIconsNew value for property showHeaderIcons
Returns:
sap.ui.commons.TreeReference 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:
booleanbShowHorizontalScrollbarNew value for property showHorizontalScrollbar
Returns:
sap.ui.commons.TreeReference 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:
stringsTitleNew value for property title
Returns:
sap.ui.commons.TreeReference 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.CSSSizesWidthNew value for property width
Returns:
sap.ui.commons.TreeReference to this in order to allow method chaining
unbindNodes(): sap.ui.commons.Tree
Unbinds aggregation nodes from model data.
Returns:
sap.ui.commons.TreeReference to this in order to allow method chaining