Google Apps Script

Class TreeItem

An item that can be contained within a Tree.

Internally, UiApp widgets are built on top of the Google Web Toolkit, and it can sometimes be helpful to look at the GWT documentation directly. You can find the TreeItem documentation here.

Methods

MethodReturn typeBrief description
addItem(text)TreeItemAdds a new child tree item containing the specified HTML.
addItem(item)TreeItemAdds a TreeItem as a child to this TreeItem.
addItem(widget)TreeItemAdds a new child tree item containing the specified widget.
addStyleDependentName(styleName)TreeItemSets the dependent style name of this TreeItem.
addStyleName(styleName)TreeItemAdds a style name to this TreeItem.
clear()TreeItemRemoves all children.
getId()StringReturns the id that has been assigned to this object.
getTag()StringGets the text tag of this TreeItem.
getType()StringGets the type of this object.
setHTML(html)TreeItemSets the HTML content of this TreeItem.
setHeight(height)TreeItemSets the height of this TreeItem.
setId(id)TreeItemSets the id of this TreeItem.
setPixelSize(width, height)TreeItemSets the size of this TreeItem in pixels.
setSelected(selected)TreeItemSet whether this item is selected.
setSize(width, height)TreeItemSets the size of this TreeItem.
setState(open)TreeItemSets whether this TreeItem is open or closed.
setState(open, fireEvents)TreeItemSets whether this TreeItem is open or closed and optionally fire events.
setStyleAttribute(attribute, value)TreeItemSets one of this TreeItem's style attributes to a new value.
setStyleAttributes(attributes)TreeItemSets this TreeItem's style attributes.
setStyleName(styleName)TreeItemSets the style name of this TreeItem.
setStylePrimaryName(styleName)TreeItemSets the primary style name of this TreeItem.
setTag(tag)TreeItemSets the text tag of this TreeItem.
setText(text)TreeItemSet the display text of this TreeItem.
setTitle(title)TreeItemSets the hover title of this TreeItem.
setVisible(visible)TreeItemSets whether this TreeItem is visible.
setWidget(widget)TreeItemSets the widget to be shown inside this TreeItem.
setWidth(width)TreeItemSets the width of this TreeItem.

Detailed documentation

addItem(text)

Adds a new child tree item containing the specified HTML.

Parameters

NameTypeDescription
textStringthe new item's text, treated as HTML.

Return

TreeItem — the TreeItem itself, useful for chaining.


addItem(item)

Adds a TreeItem as a child to this TreeItem.

Parameters

NameTypeDescription
itemTreeItemthe child item.

Return

TreeItem — the TreeItem itself, useful for chaining.


addItem(widget)

Adds a new child tree item containing the specified widget.

Parameters

NameTypeDescription
widgetWidgetthe widget to put inside the new item.

Return

TreeItem — the TreeItem itself, useful for chaining.


addStyleDependentName(styleName)

Sets the dependent style name of this TreeItem.

This is useful for debugging but is otherwise of minimal use since there is no way to use custom stylesheets in UiApp.

Parameters

NameTypeDescription
styleNameStringthe new style name.

Return

TreeItem — the TreeItem itself, useful for chaining.


addStyleName(styleName)

Adds a style name to this TreeItem.

This is useful for debugging but is otherwise of minimal use since there is no way to use custom stylesheets in UiApp.

Parameters

NameTypeDescription
styleNameStringthe new style name.

Return

TreeItem — the TreeItem itself, useful for chaining.


clear()

Removes all children.

Return

TreeItem — the TreeItem itself, useful for chaining.


getId()

Returns the id that has been assigned to this object.

This can be used in conjunction with app.getElementById() to retrieve a reference to this object.

Return

String — the id that has been assigned to this object


getTag()

Gets the text tag of this TreeItem.

Return

String — the text tag.


getType()

Gets the type of this object.

Return

String — the object type


setHTML(html)

Sets the HTML content of this TreeItem.

Parameters

NameTypeDescription
htmlStringthe new HTML

Return

TreeItem — the TreeItem itself, useful for chaining.


setHeight(height)

Sets the height of this TreeItem.

Parameters

NameTypeDescription
heightStringthe new height in any CSS unit such as "10px" or "50%".

Return

TreeItem — the TreeItem itself, useful for chaining.


setId(id)

Sets the id of this TreeItem.

Parameters

NameTypeDescription
idStringthe new id, which can be used to retrieve the TreeItem from app.getElementById(id).

Return

TreeItem — the TreeItem itself, useful for chaining.


setPixelSize(width, height)

Sets the size of this TreeItem in pixels.

Parameters

NameTypeDescription
widthIntegerthe new width in pixels.
heightIntegerthe new height in pixels.

Return

TreeItem — the TreeItem itself, useful for chaining.


setSelected(selected)

Set whether this item is selected.

Parameters

NameTypeDescription
selectedBooleanwhether this item is selected.

Return

TreeItem — the TreeItem itself, useful for chaining.


setSize(width, height)

Sets the size of this TreeItem.

Parameters

NameTypeDescription
widthStringthe new width in any CSS unit such as "10px" or "50%".
heightStringthe new height in any CSS unit such as "10px" or "50%".

Return

TreeItem — the TreeItem itself, useful for chaining.


setState(open)

Sets whether this TreeItem is open or closed.

This does not fire events if the state changes.

Parameters

NameTypeDescription
openBooleanwhether it's open or closed.

Return

TreeItem — the TreeItem itself, useful for chaining.


setState(open, fireEvents)

Sets whether this TreeItem is open or closed and optionally fire events.

This does not fire events if the state changes.

Parameters

NameTypeDescription
openBooleanwhether it's open or closed.
fireEventsBooleanwhether to fire events if the state changes.

Return

TreeItem — the TreeItem itself, useful for chaining.


setStyleAttribute(attribute, value)

Sets one of this TreeItem's style attributes to a new value. Valid attributes are listed here; the values for each attribute are the same as those available in CSS style sheets.

 
// Change the widget's background to black and text color to green.
 widget.setStyleAttribute("background", "black")
     .setStyleAttribute("color", "green");
 

Parameters

NameTypeDescription
attributeStringthe CSS attribute, in camel-case ("fontSize", not "font-size"), as listed here
valueStringthe CSS value

Return

TreeItem — the TreeItem itself, useful for chaining.


setStyleAttributes(attributes)

Sets this TreeItem's style attributes. This is a convenience method that is equivalent to calling setStyleAttribute with every key/value pair in the attributes object. Valid attributes are listed here; the values for each attribute are the same as those available in CSS style sheets.

 
// Change the widget's background to black and text color to green.
 widget.setStyleAttributes({background: "black", color: "green"});
 

Parameters

NameTypeDescription
attributesObjectan object of key/value pairs for the CSS attributes and values to set; valid attributes are listed here

Return

TreeItem — the TreeItem itself, useful for chaining.


setStyleName(styleName)

Sets the style name of this TreeItem.

This is useful for debugging but is otherwise of minimal use since there is no way to use custom stylesheets in UiApp.

Parameters

NameTypeDescription
styleNameStringthe new style name.

Return

TreeItem — the TreeItem itself, useful for chaining.


setStylePrimaryName(styleName)

Sets the primary style name of this TreeItem.

This is useful for debugging but is otherwise of minimal use since there is no way to use custom stylesheets in UiApp.

Parameters

NameTypeDescription
styleNameStringthe new style name.

Return

TreeItem — the TreeItem itself, useful for chaining.


setTag(tag)

Sets the text tag of this TreeItem.

Parameters

NameTypeDescription
tagStringthe new text tag, which can be anything you wish to store with the widget.

Return

TreeItem — the TreeItem itself, useful for chaining.


setText(text)

Set the display text of this TreeItem.

Parameters

NameTypeDescription
textStringthe new text.

Return

TreeItem — the TreeItem itself, useful for chaining.


setTitle(title)

Sets the hover title of this TreeItem.

Not all browsers will show this.

Parameters

NameTypeDescription
titleStringthe hover title.

Return

TreeItem — the TreeItem itself, useful for chaining.


setVisible(visible)

Sets whether this TreeItem is visible.

Parameters

NameTypeDescription
visibleBooleanwhether this TreeItem should be visible or not.

Return

TreeItem — the TreeItem itself, useful for chaining.


setWidget(widget)

Sets the widget to be shown inside this TreeItem.

Parameters

NameTypeDescription
widgetWidgetthe widget to put inside this TreeItem.

Return

TreeItem — the TreeItem itself, useful for chaining.


setWidth(width)

Sets the width of this TreeItem.

Parameters

NameTypeDescription
widthStringthe new width in any CSS unit such as "10px" or "50%".

Return

TreeItem — the TreeItem itself, useful for chaining.

Deprecated methods

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.