Google Apps Script

Class UiInstance

A representation of a user interface.

You can use this to create a new user interface or manipulate an existing one.

Methods

MethodReturn typeBrief description
add(child)UiInstanceAdds a new widget to this application.
close()UiInstanceClose the app.
createAbsolutePanel()AbsolutePanelCreates a new AbsolutePanel.
createAnchor(text, asHtml, href)AnchorCreates a new Anchor.
createAnchor(text, href)AnchorCreates a new Anchor.
createButton()ButtonCreates a new Button.
createButton(html)ButtonCreates a new Button.
createButton(html, clickHandler)ButtonCreates a new Button.
createCaptionPanel()CaptionPanelCreates a new CaptionPanel.
createCaptionPanel(caption)CaptionPanelCreates a new CaptionPanel.
createCaptionPanel(caption, asHtml)CaptionPanelCreates a new CaptionPanel.
createCheckBox()CheckBoxCreates a new CheckBox.
createCheckBox(label)CheckBoxCreates a new CheckBox.
createCheckBox(label, asHtml)CheckBoxCreates a new CheckBox.
createClientHandler()ClientHandlerCreates a new ClientHandler.
createDateBox()DateBoxCreates a new DateBox.
createDatePicker()DatePickerCreates a new DatePicker.
createDecoratedStackPanel()DecoratedStackPanelCreates a new DecoratedStackPanel.
createDecoratedTabBar()DecoratedTabBarCreates a new DecoratedTabBar.
createDecoratedTabPanel()DecoratedTabPanelCreates a new DecoratedTabPanel.
createDecoratorPanel()DecoratorPanelCreates a new DecoratorPanel.
createDialogBox()DialogBoxCreates a new DialogBox.
createDialogBox(autoHide)DialogBoxCreates a new DialogBox.
createDialogBox(autoHide, modal)DialogBoxCreates a new DialogBox.
createDocsListDialog()DocsListDialogCreate a new DocsListDialog.
createFileUpload()FileUploadCreates a new FileUpload.
createFlexTable()FlexTableCreates a new FlexTable.
createFlowPanel()FlowPanelCreates a new FlowPanel.
createFocusPanel()FocusPanelCreates a new FocusPanel.
createFocusPanel(child)FocusPanelCreates a new FocusPanel with a specified child Widget.
createFormPanel()FormPanelCreates a new FormPanel.
createGrid()GridCreates a new Grid.
createGrid(rows, columns)GridCreates a new Grid with a specified size.
createHTML()HTMLCreates a new HTML with no text.
createHTML(html)HTMLCreates a new HTML with the specified text.
createHTML(html, wordWrap)HTMLCreates a new HTML with the specified text.
createHidden()HiddenCreates a new Hidden.
createHidden(name)HiddenCreates a new Hidden with a specified name.
createHidden(name, value)HiddenCreates a new Hidden with a specified name and value.
createHorizontalPanel()HorizontalPanelCreates a new HorizontalPanel.
createImage()ImageCreates a new Image.
createImage(url)ImageCreates a new Image with the specified URL.
createImage(url, left, top, width, height)ImageCreates a new Image with the specified URL and clipping rectangle.
createInlineLabel()InlineLabelCreates a new InlineLabel with no text.
createInlineLabel(text)InlineLabelCreates a new InlineLabel with the specified text.
createLabel()LabelCreates a new Label with no text.
createLabel(text)LabelCreates a new Label with the specified text.
createLabel(text, wordWrap)LabelCreates a new Label with the specified text.
createListBox()ListBoxCreates a new ListBox.
createListBox(isMultipleSelect)ListBoxCreates a new ListBox.
createMenuBar()MenuBarCreates a new MenuBar.
createMenuBar(vertical)MenuBarCreates a new MenuBar.
createMenuItem(text, asHtml, command)MenuItemCreates a new MenuItem.
createMenuItem(text, command)MenuItemCreates a new MenuItem.
createMenuItemSeparator()MenuItemSeparatorCreates a new MenuItemSeparator.
createPasswordTextBox()PasswordTextBoxCreates a new PasswordTextBox.
createPopupPanel()PopupPanelCreates a new PopupPanel.
createPopupPanel(autoHide)PopupPanelCreates a new PopupPanel.
createPopupPanel(autoHide, modal)PopupPanelCreates a new PopupPanel.
createPushButton()PushButtonCreates a new PushButton.
createPushButton(upText)PushButtonCreates a new PushButton.
createPushButton(upText, clickHandler)PushButtonCreates a new PushButton.
createPushButton(upText, downText)PushButtonCreates a new PushButton.
createPushButton(upText, downText, clickHandler)PushButtonCreates a new PushButton.
createRadioButton(name)RadioButtonCreates a new RadioButton.
createRadioButton(name, label)RadioButtonCreates a new RadioButton.
createRadioButton(name, label, asHtml)RadioButtonCreates a new RadioButton.
createResetButton()ResetButtonCreates a new ResetButton.
createResetButton(html)ResetButtonCreates a new ResetButton.
createResetButton(html, clickHandler)ResetButtonCreates a new ResetButton.
createScrollPanel()ScrollPanelCreates a new ScrollPanel.
createScrollPanel(child)ScrollPanelCreates a new ScrollPanel with a specified child Widget.
createServerHandler()ServerHandlerCreates a new ServerHandler.
createServerHandler(functionName)ServerHandlerCreates a new ServerHandler.
createSimpleCheckBox()SimpleCheckBoxCreates a new SimpleCheckBox.
createSimplePanel()SimplePanelCreates a new SimplePanel.
createSimpleRadioButton(name)SimpleRadioButtonCreates a new SimpleRadioButton.
createSplitLayoutPanel()SplitLayoutPanelCreates a new SplitLayoutPanel.
createStackPanel()StackPanelCreates a new StackPanel.
createSubmitButton()SubmitButtonCreates a new SubmitButton.
createSubmitButton(html)SubmitButtonCreates a new SubmitButton.
createTabBar()TabBarCreates a new TabBar.
createTabPanel()TabPanelCreates a new TabPanel.
createTextArea()TextAreaCreates a new TextArea.
createTextBox()TextBoxCreates a new TextBox.
createToggleButton()ToggleButtonCreates a new ToggleButton.
createToggleButton(upText)ToggleButtonCreates a new ToggleButton.
createToggleButton(upText, clickHandler)ToggleButtonCreates a new ToggleButton.
createToggleButton(upText, downText)ToggleButtonCreates a new ToggleButton.
createTree()TreeCreates a new Tree.
createTreeItem()TreeItemCreates a new TreeItem.
createTreeItem(text)TreeItemCreates a new TreeItem with the given text.
createTreeItem(child)TreeItemCreates a new TreeItem with the given widget.
createVerticalPanel()VerticalPanelCreates a new VerticalPanel.
getElementById(id)ComponentRetrieves a generic reference to an element stored in the application, by its id.
getId()StringReturns the id that has been assigned to this object.
isStandardsMode()BooleanGets whether the UiApp displays in HTML 'standards' mode or in 'quirks' mode.
loadComponent(componentName)ComponentLoad a GUI Builder component into UiApp, by name.
loadComponent(componentName, optAdvancedArgs)ComponentLoad a GUI Builder component into UiApp, by name.
remove(index)UiInstanceRemove the widget with the given index from the application.
remove(widget)UiInstanceRemove the given widget from the application.
setHeight(height)UiInstanceSets the application's height.
setStandardsMode(standardsMode)UiInstanceSet whether the UiApp displays in HTML 'standards' mode or in 'quirks' mode.
setStyleAttribute(attribute, value)UiInstanceSets one of the application's style attributes to a new value.
setTitle(title)UiInstanceSets the title of the application.
setWidth(width)UiInstanceSets the application's width.

Detailed documentation

add(child)

Adds a new widget to this application.

The new widget will be a part of the children widgets of this application. The new widget is added to the end of the list of widgets currently in the application.

Parameters

NameTypeDescription
childWidgetthe new widget to add to the application.

Return

UiInstance — the application itself, useful for chaining.


close()

Close the app.

This will only work if the app is being shown as a dialog, such as in a Google Spreadsheet. It will have no effect when called on an app that is published as a standalone service.

Return

UiInstance — the application itself, useful for chaining.


createAbsolutePanel()

Creates a new AbsolutePanel.

Return

AbsolutePanel — the new AbsolutePanel.


createAnchor(text, asHtml, href)

Creates a new Anchor.

This is essentially a hyperlink and represents an <a> element. This widget is based on GWT's anchor class.

Parameters

NameTypeDescription
textStringthe text to display to the user as the anchor's text.
asHtmlBooleanwhether to render that text as HTML.
hrefStringthe address to go to when the anchor is clicked.

Return

Anchor — the new Anchor.


createAnchor(text, href)

Creates a new Anchor.

This is essentially a hyperlink and represents an <a> element. This widget is based on GWT's anchor class.

Parameters

NameTypeDescription
textStringthe text to display to the user as the anchor's text.
hrefStringthe address to go to when the anchor is clicked.

Return

Anchor — the new Anchor.


createButton()

Creates a new Button.

Return

Button — the new Button.


createButton(html)

Creates a new Button.

Parameters

NameTypeDescription
htmlStringthe new Button's text, rendered as HTML.

Return

Button — the new Button.


createButton(html, clickHandler)

Creates a new Button.

Parameters

NameTypeDescription
htmlStringthe new Button's text, rendered as HTML.
clickHandlerHandlera click handler for the new button. This can be a ClientHandler or a ServerHandler.

Return

Button — the new Button.


createCaptionPanel()

Creates a new CaptionPanel.

Return

CaptionPanel — the new CaptionPanel.


createCaptionPanel(caption)

Creates a new CaptionPanel.

Parameters

NameTypeDescription
captionStringthe CaptionPanel's caption text, not rendered as HTML.

Return

CaptionPanel — the new CaptionPanel.


createCaptionPanel(caption, asHtml)

Creates a new CaptionPanel.

Parameters

NameTypeDescription
captionStringthe CaptionPanel's caption text.
asHtmlBooleanwhether to render the caption text as HTML.

Return

CaptionPanel — the new CaptionPanel.


createCheckBox()

Creates a new CheckBox.

Return

CheckBox — the new CheckBox.


createCheckBox(label)

Creates a new CheckBox.

Parameters

NameTypeDescription
labelStringthe CheckBox's label text, not rendered as HTML.

Return

CheckBox — the new CheckBox.


createCheckBox(label, asHtml)

Creates a new CheckBox.

Parameters

NameTypeDescription
labelStringthe CheckBox's label text.
asHtmlBooleanwhether to render the label text as HTML.

Return

CheckBox — the new CheckBox.


createClientHandler()

Creates a new ClientHandler.

A ClientHandler can be used anywhere a ServerHandler can be. See the documentation of ClientHandler and the User Guide to understand how to specify what a ClientHandler will do in response to an event.

Return

ClientHandler — the new ClientHandler.


createDateBox()

Creates a new DateBox.

Return

DateBox — the new DateBox.


createDatePicker()

Creates a new DatePicker.

Return

DatePicker — the new DatePicker.


createDecoratedStackPanel()

Creates a new DecoratedStackPanel.

Return

DecoratedStackPanel — the new DecoratedStackPanel.


createDecoratedTabBar()

Creates a new DecoratedTabBar.

Return

DecoratedTabBar — the new DecoratedTabBar.


createDecoratedTabPanel()

Creates a new DecoratedTabPanel.

Return

DecoratedTabPanel — the new DecoratedTabPanel.


createDecoratorPanel()

Creates a new DecoratorPanel.

Return

DecoratorPanel — the new DecoratorPanel.


createDialogBox()

Creates a new DialogBox.

The dialog will not auto-hide and is not modal.

Return

DialogBox — the new DialogBox.


createDialogBox(autoHide)

Creates a new DialogBox.

The dialog is not modal.

Parameters

NameTypeDescription
autoHideBooleanwhether the dialog should auto-hide when the user clicks outside of it.

Return

DialogBox — the new DialogBox.


createDialogBox(autoHide, modal)

Creates a new DialogBox.

Parameters

NameTypeDescription
autoHideBooleanwhether the dialog should auto-hide when the user clicks outside of it.
modalBooleanwhether the dialog is modal, meaning that keyboard or mouse events that do not target the DialogBox or its children will be ignored.

Return

DialogBox — the new DialogBox.


createDocsListDialog()

Create a new DocsListDialog.

Return

DocsListDialog — the new DocsListDialog.


createFileUpload()

Creates a new FileUpload.

Return

FileUpload — the new FileUpload.


createFlexTable()

Creates a new FlexTable.

Return

FlexTable — the new FlexTable.


createFlowPanel()

Creates a new FlowPanel.

Return

FlowPanel — the new FlowPanel.


createFocusPanel()

Creates a new FocusPanel.

Return

FocusPanel — the new FocusPanel.


createFocusPanel(child)

Creates a new FocusPanel with a specified child Widget.

Parameters

NameTypeDescription
childWidgetthe child widget.

Return

FocusPanel — the new FocusPanel.


createFormPanel()

Creates a new FormPanel.

Return

FormPanel — the new FormPanel.


createGrid()

Creates a new Grid.

Until the Grid is explicitly resized, no widgets can't be added to it.

Return

Grid — the new Grid.


createGrid(rows, columns)

Creates a new Grid with a specified size.

Parameters

NameTypeDescription
rowsIntegerthe number of rows
columnsIntegerthe number of columns

Return

Grid — the new Grid.


createHTML()

Creates a new HTML with no text.

Return

HTML — the new HTML.


createHTML(html)

Creates a new HTML with the specified text.

Parameters

NameTypeDescription
htmlStringthe HTML's text, rendered as HTML.

Return

HTML — the new HTML.


createHTML(html, wordWrap)

Creates a new HTML with the specified text.

Parameters

NameTypeDescription
htmlStringthe HTML's text, rendered as HTML.
wordWrapBooleanwhether to allow the text to wrap.

Return

HTML — the new HTML.


createHidden()

Creates a new Hidden.

Return

Hidden — the new Hidden.


createHidden(name)

Creates a new Hidden with a specified name.

Parameters

NameTypeDescription
nameStringthe hidden field's name.

Return

Hidden — the new Hidden.


createHidden(name, value)

Creates a new Hidden with a specified name and value.

Parameters

NameTypeDescription
nameStringthe hidden field's name.
valueStringthe hidden field's value.

Return

Hidden — the new Hidden.


createHorizontalPanel()

Creates a new HorizontalPanel.

Return

HorizontalPanel — the new HorizontalPanel.


createImage()

Creates a new Image.

Return

Image — the new Image.


createImage(url)

Creates a new Image with the specified URL.

Parameters

NameTypeDescription
urlStringthe URL of the image.

Return

Image — the new Image.


createImage(url, left, top, width, height)

Creates a new Image with the specified URL and clipping rectangle.

Parameters

NameTypeDescription
urlStringthe URL of the image.
leftIntegerthe left of the clipping rectangle, in pixels.
topIntegerthe top of the clipping rectangle, in pixels.
widthIntegerthe width of the clipping rectangle, in pixels.
heightIntegerthe height of the clipping rectangle, in pixels.

Return

Image — the new Image.


createInlineLabel()

Creates a new InlineLabel with no text.

Return

InlineLabel — the new InlineLabel.


createInlineLabel(text)

Creates a new InlineLabel with the specified text.

Parameters

NameTypeDescription
textStringthe label's text, not rendered as HTML.

Return

InlineLabel — the new InlineLabel.


createLabel()

Creates a new Label with no text.

Return

Label — the new Label.


createLabel(text)

Creates a new Label with the specified text.

Parameters

NameTypeDescription
textStringthe label's text, not rendered as HTML.

Return

Label — the new Label.


createLabel(text, wordWrap)

Creates a new Label with the specified text.

Parameters

NameTypeDescription
textStringthe label's text, not rendered as HTML.
wordWrapBooleanwhether to allow the text to wrap.

Return

Label — the new Label.


createListBox()

Creates a new ListBox.

The ListBox will not allow multiple selections.

Return

ListBox — the new ListBox.


createListBox(isMultipleSelect)

Creates a new ListBox.

Parameters

NameTypeDescription
isMultipleSelectBooleanwhether the ListBox should allow multiple selections.

Return

ListBox — the new ListBox.


createMenuBar()

Creates a new MenuBar.

The MenuBar will display itself horizontally.

Return

MenuBar — the new MenuBar.


createMenuBar(vertical)

Creates a new MenuBar.

Parameters

NameTypeDescription
verticalBooleanwhether the MenuBar should display itself vertically.

Return

MenuBar — the new MenuBar.


createMenuItem(text, asHtml, command)

Creates a new MenuItem.

Parameters

NameTypeDescription
textStringthe text to display for this item.
asHtmlBooleanwhether to render that text as HTML.
commandHandlerthe ClientHandler or ServerHandler to invoke when this item is selected.

Return

MenuItem — the new MenuItem.


createMenuItem(text, command)

Creates a new MenuItem.

Parameters

NameTypeDescription
textStringthe text to display for this item.
commandHandlerthe ClientHandler or ServerHandler to invoke when this item is selected.

Return

MenuItem — the new MenuItem.


createMenuItemSeparator()

Creates a new MenuItemSeparator.

Return

MenuItemSeparator — the new MenuItemSeparator.


createPasswordTextBox()

Creates a new PasswordTextBox.

Return

PasswordTextBox — the new PasswordTextBox.


createPopupPanel()

Creates a new PopupPanel.

The panel will not auto-hide and is not modal.

Return

PopupPanel — the new PopupPanel.


createPopupPanel(autoHide)

Creates a new PopupPanel.

The panel is not modal.

Parameters

NameTypeDescription
autoHideBooleanwhether the panel should auto-hide when the user clicks outside of it.

Return

PopupPanel — the new PopupPanel.


createPopupPanel(autoHide, modal)

Creates a new PopupPanel.

Parameters

NameTypeDescription
autoHideBooleanwhether the panel should auto-hide when the user clicks outside of it.
modalBooleanwhether the panel is modal, meaning that keyboard or mouse events that do not target the PopupPanel or its children will be ignored.

Return

PopupPanel — the new PopupPanel.


createPushButton()

Creates a new PushButton.

Return

PushButton — the new PushButton.


createPushButton(upText)

Creates a new PushButton.

Parameters

NameTypeDescription
upTextStringthe up text

Return

PushButton — the new PushButton.


createPushButton(upText, clickHandler)

Creates a new PushButton.

Parameters

NameTypeDescription
upTextStringthe up text
clickHandlerHandlera click handler for the new button. This can be a ClientHandler or a ServerHandler.

Return

PushButton — the new PushButton.


createPushButton(upText, downText)

Creates a new PushButton.

Parameters

NameTypeDescription
upTextStringthe up text
downTextStringthe down text.

Return

PushButton — the new PushButton.


createPushButton(upText, downText, clickHandler)

Creates a new PushButton.

Parameters

NameTypeDescription
upTextStringthe up text
downTextStringthe down text.
clickHandlerHandlera click handler for the new button. This can be a ClientHandler or a ServerHandler.

Return

PushButton — the new PushButton.


createRadioButton(name)

Creates a new RadioButton.

Parameters

NameTypeDescription
nameStringthe RadioButton's name. Names are used for grouping RadioButtons; see the documentation of RadioButton for more details.

Return

RadioButton — the new RadioButton.


createRadioButton(name, label)

Creates a new RadioButton.

Parameters

NameTypeDescription
nameStringthe RadioButton's name. Names are used for grouping RadioButtons; see the documentation of RadioButton for more details.
labelStringthe RadioButton's label text, not rendered as HTML.

Return

RadioButton — the new RadioButton.


createRadioButton(name, label, asHtml)

Creates a new RadioButton.

Parameters

NameTypeDescription
nameStringthe RadioButton's name. Names are used for grouping RadioButtons; see the documentation of RadioButton for more details.
labelStringthe RadioButton's label text.
asHtmlBooleanwhether to render that text as HTML.

Return

RadioButton — the new RadioButton.


createResetButton()

Creates a new ResetButton.

Return

ResetButton — the new ResetButton.


createResetButton(html)

Creates a new ResetButton.

Parameters

NameTypeDescription
htmlStringthe text to show on the button, rendered as HTML.

Return

ResetButton — the new ResetButton.


createResetButton(html, clickHandler)

Creates a new ResetButton.

Parameters

NameTypeDescription
htmlStringthe text to show on the button, rendered as HTML.
clickHandlerHandlera click handler for the new button. This can be a ClientHandler or a ServerHandler.

Return

ResetButton — the new ResetButton.


createScrollPanel()

Creates a new ScrollPanel.

Return

ScrollPanel — the new ScrollPanel.


createScrollPanel(child)

Creates a new ScrollPanel with a specified child Widget.

Parameters

NameTypeDescription
childWidgetthe child widget.

Return

ScrollPanel — the new ScrollPanel.


createServerHandler()

Creates a new ServerHandler.

Server handlers are used by scripts to launch script functions in response to events in the application. For example, a server handler can be added to a Button with the addClickHandler method so that the handler will be invoked when the button is clicked.

Return

ServerHandler — a new ServerHandler object.


createServerHandler(functionName)

Creates a new ServerHandler.

Server handlers are used by scripts to launch script functions in response to events in the application. For example, a server handler can be added to a Button with the addClickHandler method so that the handler will be invoked when the button is clicked.

Parameters

NameTypeDescription
functionNameStringa script function that will be executed when this handler is invoked.

Return

ServerHandler — a new ServerHandler object.


createSimpleCheckBox()

Creates a new SimpleCheckBox.

Return

SimpleCheckBox — the new SimpleCheckBox.


createSimplePanel()

Creates a new SimplePanel.

Return

SimplePanel — the new SimplePanel.


createSimpleRadioButton(name)

Creates a new SimpleRadioButton.

Parameters

NameTypeDescription
nameStringthe SimpleRadioButton's name. Names are used for grouping RadioButtons; see the documentation of SimpleRadioButton for more details.

Return

SimpleRadioButton — the new SimpleRadioButton.


createSplitLayoutPanel()

Creates a new SplitLayoutPanel.

Return

SplitLayoutPanel — the new SplitLayoutPanel.


createStackPanel()

Creates a new StackPanel.

Return

StackPanel — the new StackPanel.


createSubmitButton()

Creates a new SubmitButton.

Return

SubmitButton — the new SubmitButton.


createSubmitButton(html)

Creates a new SubmitButton.

Parameters

NameTypeDescription
htmlStringthe text to show on the button, rendered as HTML.

Return

SubmitButton — the new SubmitButton.


createTabBar()

Creates a new TabBar.

Return

TabBar — the new TabBar.


createTabPanel()

Creates a new TabPanel.

Return

TabPanel — the new TabPanel.


createTextArea()

Creates a new TextArea.

Return

TextArea — the new TextArea.


createTextBox()

Creates a new TextBox.

Return

TextBox — the new TextBox.


createToggleButton()

Creates a new ToggleButton.

Return

ToggleButton — the new ToggleButton.


createToggleButton(upText)

Creates a new ToggleButton.

Parameters

NameTypeDescription
upTextStringthe up text

Return

ToggleButton — the new ToggleButton.


createToggleButton(upText, clickHandler)

Creates a new ToggleButton.

Parameters

NameTypeDescription
upTextStringthe up text
clickHandlerHandlera click handler for the new button. This can be a ClientHandler or a ServerHandler.

Return

ToggleButton — the new ToggleButton.


createToggleButton(upText, downText)

Creates a new ToggleButton.

Parameters

NameTypeDescription
upTextStringthe up text
downTextStringthe down text.

Return

ToggleButton — the new ToggleButton.


createTree()

Creates a new Tree.

Return

Tree — the new Tree.


createTreeItem()

Creates a new TreeItem.

Return

TreeItem — the new TreeItem.


createTreeItem(text)

Creates a new TreeItem with the given text.

Parameters

NameTypeDescription
textStringthe tree item's text, not rendered as HTML.

Return

TreeItem — the new TreeItem.


createTreeItem(child)

Creates a new TreeItem with the given widget.

Parameters

NameTypeDescription
childWidgetthe widget to display on the item.

Return

TreeItem — the new TreeItem.


createVerticalPanel()

Creates a new VerticalPanel.

Return

VerticalPanel — the new VerticalPanel.


getElementById(id)

Retrieves a generic reference to an element stored in the application, by its id.

The reference is not 'aware' of whether any such widget actually exists. If there is no widget with the given id, or if there is such a widget but the method you call on it does not exist for that widget type, this will cause an error on the client when the UiInstance is returned.

This can be used to get existing widgets in the application when writing event handling code. To set a widget's id, use the method setId of the target widget. For Example:

 
function doGet() {
   var app = UiApp.createApplication();

   // create a label and set its id to 'labelId'
   var label = app.createLabel("Hello").setId('labelId');

   var button = app.createButton("OK", app.createServerHandler('onClick'));
   app.add(label).add(button);
   return app;
 }

 function onClick(event) {
   var app = UiApp.getActiveApplication();

   // retrieve the label from the application by id
   var label = app.getElementById('labelId');
   label.setText("World!");
   return app;
 }
 

Parameters

NameTypeDescription
idStringthe id of the requested widget.

Return

Component — a reference to a widget with that id


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


isStandardsMode()

Gets whether the UiApp displays in HTML 'standards' mode or in 'quirks' mode.

Return

Boolean — whether the UiApp displays in HTML 'standards' mode or in 'quirks' mode


loadComponent(componentName)

Load a GUI Builder component into UiApp, by name.

Parameters

NameTypeDescription
componentNameStringthe name of the component to load

Return

Component — the component, which can be added to an app


loadComponent(componentName, optAdvancedArgs)

Load a GUI Builder component into UiApp, by name.

Parameters

NameTypeDescription
componentNameStringthe name of the component to load
optAdvancedArgsObjectan object with advanced settings such as 'prefix', which gets added to the id of any widget inside the component, and 'z-index', which specifies a base z-index that gets added to the z-index of any widgets inside the component.

Return

Component — the component, which can be added to an app


remove(index)

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

Parameters

NameTypeDescription
indexIntegerthe index of the widget to remove.

Return

UiInstance — the application itself, useful for chaining.


remove(widget)

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

Parameters

NameTypeDescription
widgetWidgetthe widget to remove.

Return

UiInstance — the application itself, useful for chaining.


setHeight(height)

Sets the application's height.

This affects the height of the application when run as a service or the height of a dialog when an application is shown inside a spreadsheet.

Parameters

NameTypeDescription
heightIntegerthe new height value in pixels.

Return

UiInstance — the application itself, useful for chaining.


setStandardsMode(standardsMode)

Set whether the UiApp displays in HTML 'standards' mode or in 'quirks' mode.

By default UiApp uses 'quirks' mode unless you use a GUI Builder component with loadComponent, in which case it defaults to 'standards'.

Parameters

NameTypeDescription
standardsModeBooleanwhether to use standards mode

Return

UiInstance — this UiInstance, useful for chaining


setStyleAttribute(attribute, value)

Sets one of the application's style attributes to a new value.

Possible attributes are the same as those available in CSS style sheets. Since some CSS code may be malicious, attributes are whitelisted explicitly and therefore some CSS attributes may not be available.

The following example shows an application which background and text color is changed:

 
function doGet() {
   var app = UiApp.createApplication();

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

   // create a label
   var label = app.createLabel("Hello World!");

   app.add(label)
   return app;
 }
 

Parameters

NameTypeDescription
attributeStringthe CSS attribute, in camelCase. ("fontSize", not "font-size").
valueStringthe CSS value

Return

UiInstance — the application itself, useful for chaining.


setTitle(title)

Sets the title of the application.

If this application will be run as a service, this will be used as the title of the page. If this application will be run as a dialog (for example inside a spreadsheet) it will be the title of the dialog's window.

Parameters

NameTypeDescription
titleStringthe string to be used as the application's title.

Return

UiInstance — the application itself, useful for chaining.


setWidth(width)

Sets the application's width.

This affects the width of the application when run as a service or the width of a dialog when an application is shown inside a spreadsheet.

Parameters

NameTypeDescription
widthIntegerthe new width value in pixels.

Return

UiInstance — the application 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.