Google Apps Script

Class StackPanel

A panel that stacks its children vertically, displaying only one at a time, with a header for each child which the user can click to display.

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 StackPanel documentation here.

Methods

MethodReturn typeBrief description
add(widget)StackPanelAdd a widget to the StackPanel.
add(widget, text)StackPanelAdds a widget to the stack with the given header text.
add(widget, text, asHtml)StackPanelAdds a widget to the stack with the given header text.
addStyleDependentName(styleName)StackPanelSets the dependent style name of this StackPanel.
addStyleName(styleName)StackPanelAdds a style name to this StackPanel.
clear()StackPanelRemove all widgets from the StackPanel.
getId()StringReturns the id that has been assigned to this object.
getTag()StringGets the text tag of this StackPanel.
getType()StringGets the type of this object.
remove(index)StackPanelRemove the widget with the given index from the StackPanel.
remove(widget)StackPanelRemove the given widget from the StackPanel.
setHeight(height)StackPanelSets the height of this StackPanel.
setId(id)StackPanelSets the id of this StackPanel.
setPixelSize(width, height)StackPanelSets the size of this StackPanel in pixels.
setSize(width, height)StackPanelSets the size of this StackPanel.
setStackText(index, text)StackPanelSets the text associated with a child by its index.
setStackText(index, text, asHtml)StackPanelSets the text associated with a child by its index.
setStyleAttribute(attribute, value)StackPanelSets one of this StackPanel's style attributes to a new value.
setStyleAttributes(attributes)StackPanelSets this StackPanel's style attributes.
setStyleName(styleName)StackPanelSets the style name of this StackPanel.
setStylePrimaryName(styleName)StackPanelSets the primary style name of this StackPanel.
setTag(tag)StackPanelSets the text tag of this StackPanel.
setTitle(title)StackPanelSets the hover title of this StackPanel.
setVisible(visible)StackPanelSets whether this StackPanel is visible.
setWidth(width)StackPanelSets the width of this StackPanel.

Detailed documentation

add(widget)

Add a widget to the StackPanel.

Parameters

NameTypeDescription
widgetWidgetthe widget to add.

Return

StackPanel — the StackPanel itself, useful for chaining.


add(widget, text)

Adds a widget to the stack with the given header text.

Parameters

NameTypeDescription
widgetWidgetthe widget to add.
textStringthe new header text.

Return

StackPanel — the StackPanel itself, useful for chaining.


add(widget, text, asHtml)

Adds a widget to the stack with the given header text.

Parameters

NameTypeDescription
widgetWidgetthe widget to add.
textStringthe new header text.
asHtmlBooleanwhether to treat the text as HTML.

Return

StackPanel — the StackPanel itself, useful for chaining.


addStyleDependentName(styleName)

Sets the dependent style name of this StackPanel.

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

StackPanel — the StackPanel itself, useful for chaining.


addStyleName(styleName)

Adds a style name to this StackPanel.

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

StackPanel — the StackPanel itself, useful for chaining.


clear()

Remove all widgets from the StackPanel.

Return

StackPanel — the StackPanel 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 StackPanel.

Return

String — the text tag.


getType()

Gets the type of this object.

Return

String — the object type


remove(index)

Remove the widget with the given index from the StackPanel. Indexes begin from 0. This will fail if the index is greater than or equal to the number of elements in the StackPanel.

Parameters

NameTypeDescription
indexIntegerthe index of the widget to remove.

Return

StackPanel — the StackPanel itself, useful for chaining.


remove(widget)

Remove the given widget from the StackPanel. This will fail if the widget is not actually a child of the StackPanel.

Parameters

NameTypeDescription
widgetWidgetthe widget to remove.

Return

StackPanel — the StackPanel itself, useful for chaining.


setHeight(height)

Sets the height of this StackPanel.

Parameters

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

Return

StackPanel — the StackPanel itself, useful for chaining.


setId(id)

Sets the id of this StackPanel.

Parameters

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

Return

StackPanel — the StackPanel itself, useful for chaining.


setPixelSize(width, height)

Sets the size of this StackPanel in pixels.

Parameters

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

Return

StackPanel — the StackPanel itself, useful for chaining.


setSize(width, height)

Sets the size of this StackPanel.

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

StackPanel — the StackPanel itself, useful for chaining.


setStackText(index, text)

Sets the text associated with a child by its index.

Parameters

NameTypeDescription
indexIntegerthe index of the stack element whose text we want to change.
textStringthe new text.

Return

StackPanel — the StackPanel itself, useful for chaining.


setStackText(index, text, asHtml)

Sets the text associated with a child by its index.

Parameters

NameTypeDescription
indexIntegerthe index of the stack element whose text we want to change.
textStringthe new text.
asHtmlBooleanwhether to treat the text as HTML.

Return

StackPanel — the StackPanel itself, useful for chaining.


setStyleAttribute(attribute, value)

Sets one of this StackPanel'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

StackPanel — the StackPanel itself, useful for chaining.


setStyleAttributes(attributes)

Sets this StackPanel'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

StackPanel — the StackPanel itself, useful for chaining.


setStyleName(styleName)

Sets the style name of this StackPanel.

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

StackPanel — the StackPanel itself, useful for chaining.


setStylePrimaryName(styleName)

Sets the primary style name of this StackPanel.

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

StackPanel — the StackPanel itself, useful for chaining.


setTag(tag)

Sets the text tag of this StackPanel.

Parameters

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

Return

StackPanel — the StackPanel itself, useful for chaining.


setTitle(title)

Sets the hover title of this StackPanel.

Not all browsers will show this.

Parameters

NameTypeDescription
titleStringthe hover title.

Return

StackPanel — the StackPanel itself, useful for chaining.


setVisible(visible)

Sets whether this StackPanel is visible.

Parameters

NameTypeDescription
visibleBooleanwhether this StackPanel should be visible or not.

Return

StackPanel — the StackPanel itself, useful for chaining.


setWidth(width)

Sets the width of this StackPanel.

Parameters

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

Return

StackPanel — the StackPanel 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.