class sap.ui.commons.Tree

Control sample: sap.ui.commons.Tree
Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/ui/commons/Tree
Application Component: CA-UI5-CTR

Simple tree to display item in a hierarchical way


Constructor

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#constructor for a general description of the syntax of the settings object.

new sap.ui.commons.Tree(sId?, mSettings?)
Param Type Default Value Description
sId? string

id for the new control, generated automatically if no id is given

mSettings? object

initial settings for the new control


Properties

Name Type Default Value Description
height sap.ui.core.CSSSize auto

Tree height

Visibility: public
minWidth sap.ui.core.CSSSize

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

Visibility: public
selectionMode sap.ui.commons.TreeSelectionMode Legacy

Selection mode of the Tree.

Visibility: public
showHeader boolean true

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

Visibility: public
showHeaderIcons boolean true

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

Visibility: public
showHorizontalScrollbar boolean false

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

Visibility: public
title string

Tree title

Visibility: public
width sap.ui.core.CSSSize auto

Tree width

Visibility: public

Aggregations

Default Aggregation: nodes

Name Cardinality Type Description
nodes (default) 0..n sap.ui.commons.TreeNode

First level nodes


Events Overview

Event Description
select

Event is fired when a tree node is selected.

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

selectionChange

fired when the selection of the tree has been changed

select

Event is fired when a tree node is selected.

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

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
node sap.ui.commons.TreeNode

The node which has been selected.

nodeContext object

The binding context of the selected node.

selectionChange

fired when the selection of the tree has been changed

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
nodes sap.ui.commons.TreeNode[]

The nodes which has been selected.

nodeContexts object[]

The binding context of the selected nodes.


Methods Overview

Method Description
addNode

Adds some node to the aggregation nodes.

attachSelect

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.

attachSelectionChange

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

bindNodes

Binds aggregation nodes to model data.

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

collapseAll

Collapses all nodes in the tree.

destroyNodes

Destroys all the nodes in the aggregation nodes.

detachSelect

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.

detachSelectionChange

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.

expandAll

Expands all nodes in the tree.

sap.ui.commons.Tree.extend

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.

fireSelect

Fires event select to attached listeners.

Listeners may prevent the default action of this event by calling the preventDefault method on the event object. The return value of this method indicates whether the default action should be executed.

fireSelectionChange

Fires event selectionChange to attached listeners.

getHeight

Gets current value of property height.

Tree height

Default value is 'auto'.

sap.ui.commons.Tree.getMetadata

Returns a metadata object for class sap.ui.commons.Tree.

getMinWidth

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

getNodeByContext

Returns the node with the given context, or null if no such node currently exists.

getNodes

Gets content of aggregation nodes.

First level nodes

getSelectionMode

Gets current value of property selectionMode.

Selection mode of the Tree.

Default value is Legacy.

getShowHeader

Gets current value of property showHeader.

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

Default value is true.

getShowHeaderIcons

Gets current value of property showHeaderIcons.

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

Default value is true.

getShowHorizontalScrollbar

Gets current value of property showHorizontalScrollbar.

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

Default value is false.

getTitle

Gets current value of property title.

Tree title

getWidth

Gets current value of property width.

Tree width

Default value is 'auto'.

indexOfNode

Checks for the provided sap.ui.commons.TreeNode in the aggregation nodes. and returns its index if found or -1 otherwise.

insertNode

Inserts a node into the aggregation nodes.

removeAllNodes

Removes all the controls from the aggregation nodes.

Additionally, it unregisters them from the hosting UIArea.

removeNode

Removes a node from the aggregation nodes.

setHeight

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'.

setMinWidth

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.

setSelectionMode

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.

setShowHeader

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.

setShowHeaderIcons

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.

setShowHorizontalScrollbar

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.

setTitle

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.

setWidth

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'.

unbindNodes

Unbinds aggregation nodes from model data.

addNode

Adds some node to the aggregation nodes.

Param Type DefaultValue Description
oNode sap.ui.commons.TreeNode

The node to add; if empty, nothing is inserted

attachSelect

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.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.ui.commons.Tree itself

attachSelectionChange

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

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.ui.commons.Tree itself

bindNodes

Binds aggregation nodes to model data.

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

Param Type DefaultValue Description
oBindingInfo sap.ui.base.ManagedObject.AggregationBindingInfo

The binding information

collapseAll

Collapses all nodes in the tree.

destroyNodes

Destroys all the nodes in the aggregation nodes.

detachSelect

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.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

detachSelectionChange

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.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

expandAll

Expands all nodes in the tree.

sap.ui.commons.Tree.extend

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.

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

fireSelect

Fires event select to attached listeners.

Listeners may prevent the default action of this event by calling the preventDefault method on the event object. The return value of this method indicates whether the default action should be executed.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

node sap.ui.commons.TreeNode

The node which has been selected.

nodeContext object

The binding context of the selected node.

fireSelectionChange

Fires event selectionChange to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

nodes sap.ui.commons.TreeNode[]

The nodes which has been selected.

nodeContexts object[]

The binding context of the selected nodes.

getHeight

Gets current value of property height.

Tree height

Default value is 'auto'.

sap.ui.commons.Tree.getMetadata

Returns a metadata object for class sap.ui.commons.Tree.

getMinWidth

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

getNodeByContext

Returns the node with the given context, or null if no such node currently exists.

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

The context of the node to be retrieved

getNodes

Gets content of aggregation nodes.

First level nodes

getSelectionMode

Gets current value of property selectionMode.

Selection mode of the Tree.

Default value is Legacy.

getShowHeader

Gets current value of property showHeader.

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

Default value is true.

getShowHeaderIcons

Gets current value of property showHeaderIcons.

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

Default value is true.

getShowHorizontalScrollbar

Gets current value of property showHorizontalScrollbar.

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

Default value is false.

getTitle

Gets current value of property title.

Tree title

getWidth

Gets current value of property width.

Tree width

Default value is 'auto'.

indexOfNode

Checks for the provided sap.ui.commons.TreeNode in the aggregation nodes. and returns its index if found or -1 otherwise.

Param Type DefaultValue Description
oNode sap.ui.commons.TreeNode

The node whose index is looked for

insertNode

Inserts a node into the aggregation nodes.

Param Type DefaultValue Description
oNode sap.ui.commons.TreeNode

The node to insert; if empty, nothing is inserted

iIndex int

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

removeAllNodes

Removes all the controls from the aggregation nodes.

Additionally, it unregisters them from the hosting UIArea.

removeNode

Removes a node from the aggregation nodes.

Param Type DefaultValue Description
vNode int string sap.ui.commons.TreeNode

The node to remove or its index or id

setHeight

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'.

Param Type DefaultValue Description
sHeight sap.ui.core.CSSSize 'auto'

New value for property height

setMinWidth

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.

Param Type DefaultValue Description
sMinWidth sap.ui.core.CSSSize

New value for property minWidth

setSelectionMode

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.

Param Type DefaultValue Description
sSelectionMode sap.ui.commons.TreeSelectionMode Legacy

New value for property selectionMode

setShowHeader

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.

Param Type DefaultValue Description
bShowHeader boolean true

New value for property showHeader

setShowHeaderIcons

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.

Param Type DefaultValue Description
bShowHeaderIcons boolean true

New value for property showHeaderIcons

setShowHorizontalScrollbar

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.

Param Type DefaultValue Description
bShowHorizontalScrollbar boolean false

New value for property showHorizontalScrollbar

setTitle

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.

Param Type DefaultValue Description
sTitle string

New value for property title

setWidth

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'.

Param Type DefaultValue Description
sWidth sap.ui.core.CSSSize 'auto'

New value for property width

unbindNodes

Unbinds aggregation nodes from model data.