Google Apps Script

Class FlexTable

A flexible table that creates cells on demand. It can be jagged (that is, each row can contain a different number of cells) and individual cells can be set to span multiple rows or columns.

Here is an example of how to use this widget:

 
function doGet() {
   var app = UiApp.createApplication();
   app.add(app.createFlexTable()
     .insertRow(0).insertRow(0).insertRow(0)
     .insertCell(0, 0)
     .insertCell(0, 1)
     .insertCell(0, 2)
     .insertCell(1, 0)
     .insertCell(1, 1)
     .insertCell(2, 0)
     .setBorderWidth(5).setCellPadding(10).setCellSpacing(10));
   return app;
 }
 

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

Methods

MethodReturn typeBrief description
addCell(row)FlexTableAppends a cell to the specified row.
addClickHandler(handler)FlexTableAdd a handler for click events.
addStyleDependentName(styleName)FlexTableSets the dependent style name of this FlexTable.
addStyleName(styleName)FlexTableAdds a style name to this FlexTable.
clear()FlexTableRemove all widgets from the FlexTable.
getId()StringReturns the id that has been assigned to this object.
getTag()StringGets the text tag of this FlexTable.
getType()StringGets the type of this object.
insertCell(beforeRow, beforeColumn)FlexTableInserts a cell into the FlexTable.
insertRow(beforeRow)FlexTableInserts a row into the FlexTable before the given row.
removeCell(row, column)FlexTableRemoves the specified cell from the FlexTable.
removeCells(row, column, num)FlexTableRemoves a number of cells from one row in the FlexTable.
removeRow(row)FlexTableRemoves the specified row from the FlexTable.
setBorderWidth(width)FlexTableSets the border width.
setCellPadding(padding)FlexTableSets the padding within cells.
setCellSpacing(spacing)FlexTableSets the spacing between cells.
setColumnStyleAttribute(column, attribute, value)FlexTableSets a CSS style on a column of this FlexTable.
setColumnStyleAttributes(column, attributes)FlexTableSets a CSS style on a column of this FlexTable.
setHeight(height)FlexTableSets the height of this FlexTable.
setId(id)FlexTableSets the id of this FlexTable.
setPixelSize(width, height)FlexTableSets the size of this FlexTable in pixels.
setRowStyleAttribute(row, attribute, value)FlexTableSets a CSS style on a row of this FlexTable.
setRowStyleAttributes(row, attributes)FlexTableSets a CSS style on a row of this FlexTable.
setSize(width, height)FlexTableSets the size of this FlexTable.
setStyleAttribute(row, column, attribute, value)FlexTableSets a CSS style on a cell of this FlexTable.
setStyleAttribute(attribute, value)FlexTableSets one of this FlexTable's style attributes to a new value.
setStyleAttributes(row, column, attributes)FlexTableSets a CSS style on a cell of this FlexTable.
setStyleAttributes(attributes)FlexTableSets this FlexTable's style attributes.
setStyleName(styleName)FlexTableSets the style name of this FlexTable.
setStylePrimaryName(styleName)FlexTableSets the primary style name of this FlexTable.
setTag(tag)FlexTableSets the text tag of this FlexTable.
setText(row, column, text)FlexTableSets the contents of a given cell to the given text.
setTitle(title)FlexTableSets the hover title of this FlexTable.
setVisible(visible)FlexTableSets whether this FlexTable is visible.
setWidget(row, column, widget)FlexTableSets the widget in a given cell.
setWidth(width)FlexTableSets the width of this FlexTable.

Detailed documentation

addCell(row)

Appends a cell to the specified row.

This will cause an error if the row does not exist.

Parameters

NameTypeDescription
rowIntegerthe row to which the new cell will be added.

Return

FlexTable — the FlexTable itself, useful for chaining.


addClickHandler(handler)

Add a handler for click events.

Note that you can have multiple handlers for the same event on the same widget. They will be called in the order that they were added to the widget, although ServerHandlers may appear to happen simultaneously.

The handler passes back some information to the server about what happened. This information can be accessed as follows:

 
function doGet() {
   var app = UiApp.createApplication();
   var button = app.createButton("a button");
   var handler = app.createServerHandler("handlerFunction");
   button.addClickHandler(handler);
   app.add(button);
   return app;
 }

 function handlerFunction(eventInfo) {
   var parameter = eventInfo.parameter;
   // the type of event, in this case "click".
   var eventType = parameter.eventType;
   // the id of the widget that fired this event.
   var source = parameter.source;
   // mouse x and y position relative to the widget that fired the event.
   var x = parameter.x;
   var y = parameter.y;
   // mouse x and y position within the browser window's client area.
   var clientX = parameter.clientX;
   var clientY = parameter.clientY;
   // mouse x and y position within the user's display.
   var screenX = parameter.screenX;
   var screenY = parameter.screenY;
   // the mouse button used. Left is 1, right is 2, and middle is 4.
   var button = parameter.button;
   // whether the various modifier keys were also pressed (true or false)
   var shift = parameter.shift;
   var alt = parameter.alt;
   var ctrl = parameter.ctrl;
   var meta = parameter.meta;
 }
 
In addition, the values of certain widgets can be sent up with the event as well, as "callback elements." See the documentation of ServerHandler for more information.

Parameters

NameTypeDescription
handlerHandlerthe handler to execute when the event occurs. This can be a ClientHandler or a ServerHandler.

Return

FlexTable — the FlexTable itself, useful for chaining.


addStyleDependentName(styleName)

Sets the dependent style name of this FlexTable.

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

FlexTable — the FlexTable itself, useful for chaining.


addStyleName(styleName)

Adds a style name to this FlexTable.

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

FlexTable — the FlexTable itself, useful for chaining.


clear()

Remove all widgets from the FlexTable.

Return

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

Return

String — the text tag.


getType()

Gets the type of this object.

Return

String — the object type


insertCell(beforeRow, beforeColumn)

Inserts a cell into the FlexTable.

This will cause an error if either the row or column do not exist.

Parameters

NameTypeDescription
beforeRowIntegerthe row before which the new cell will be added.
beforeColumnIntegerthe column before which the new cell will be added.

Return

FlexTable — the FlexTable itself, useful for chaining.


insertRow(beforeRow)

Inserts a row into the FlexTable before the given row.

This will cause an error if the row does not exist.

Parameters

NameTypeDescription
beforeRowIntegerthe row before which the new row will be added.

Return

FlexTable — the FlexTable itself, useful for chaining.


removeCell(row, column)

Removes the specified cell from the FlexTable.

Parameters

NameTypeDescription
rowIntegerthe row of the cell to remove.
columnIntegerthe column of the cell to remove.

Return

FlexTable — the FlexTable itself, useful for chaining.


removeCells(row, column, num)

Removes a number of cells from one row in the FlexTable.

Parameters

NameTypeDescription
rowIntegerthe row of the cells to be removed.
columnIntegerthe column of the first cell to be removed.
numIntegerthe number of cells to be removed.

Return

FlexTable — the FlexTable itself, useful for chaining.


removeRow(row)

Removes the specified row from the FlexTable.

Parameters

NameTypeDescription
rowIntegerthe row to be removed.

Return

FlexTable — the FlexTable itself, useful for chaining.


setBorderWidth(width)

Sets the border width.

Parameters

NameTypeDescription
widthIntegerthe border width, in pixels.

Return

FlexTable — the FlexTable itself, useful for chaining.


setCellPadding(padding)

Sets the padding within cells.

Parameters

NameTypeDescription
paddingIntegerthe padding, in pixels.

Return

FlexTable — the FlexTable itself, useful for chaining.


setCellSpacing(spacing)

Sets the spacing between cells.

Parameters

NameTypeDescription
spacingIntegerthe spacing, in pixels.

Return

FlexTable — the FlexTable itself, useful for chaining.


setColumnStyleAttribute(column, attribute, value)

Sets a CSS style on a column of this FlexTable.

Parameters

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

Return

FlexTable — the FlexTable itself, useful for chaining.


setColumnStyleAttributes(column, attributes)

Sets a CSS style on a column of this FlexTable.

Parameters

NameTypeDescription
columnIntegerthe column number.
attributesObjectthe CSS attributes and values to set.

Return

FlexTable — the FlexTable itself, useful for chaining.


setHeight(height)

Sets the height of this FlexTable.

Parameters

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

Return

FlexTable — the FlexTable itself, useful for chaining.


setId(id)

Sets the id of this FlexTable.

Parameters

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

Return

FlexTable — the FlexTable itself, useful for chaining.


setPixelSize(width, height)

Sets the size of this FlexTable in pixels.

Parameters

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

Return

FlexTable — the FlexTable itself, useful for chaining.


setRowStyleAttribute(row, attribute, value)

Sets a CSS style on a row of this FlexTable.

Parameters

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

Return

FlexTable — the FlexTable itself, useful for chaining.


setRowStyleAttributes(row, attributes)

Sets a CSS style on a row of this FlexTable.

Parameters

NameTypeDescription
rowIntegerthe row number.
attributesObjectthe CSS attributes and values to set.

Return

FlexTable — the FlexTable itself, useful for chaining.


setSize(width, height)

Sets the size of this FlexTable.

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

FlexTable — the FlexTable itself, useful for chaining.


setStyleAttribute(row, column, attribute, value)

Sets a CSS style on a cell of this FlexTable.

Parameters

NameTypeDescription
rowIntegerthe row of the cell.
columnIntegerthe column of the cell.
attributeStringthe CSS attribute, in camelCase. ("fontSize", not "font-size").
valueStringthe CSS value

Return

FlexTable — the FlexTable itself, useful for chaining.


setStyleAttribute(attribute, value)

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

FlexTable — the FlexTable itself, useful for chaining.


setStyleAttributes(row, column, attributes)

Sets a CSS style on a cell of this FlexTable.

Parameters

NameTypeDescription
rowIntegerthe row of the cell.
columnIntegerthe column of the cell.
attributesObjectthe CSS attributes and values to set.

Return

FlexTable — the FlexTable itself, useful for chaining.


setStyleAttributes(attributes)

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

FlexTable — the FlexTable itself, useful for chaining.


setStyleName(styleName)

Sets the style name of this FlexTable.

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

FlexTable — the FlexTable itself, useful for chaining.


setStylePrimaryName(styleName)

Sets the primary style name of this FlexTable.

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

FlexTable — the FlexTable itself, useful for chaining.


setTag(tag)

Sets the text tag of this FlexTable.

Parameters

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

Return

FlexTable — the FlexTable itself, useful for chaining.


setText(row, column, text)

Sets the contents of a given cell to the given text. This will remove any widget in the cell if one was there.

Parameters

NameTypeDescription
rowIntegerthe row of the cell.
columnIntegerthe column of the cell.
textStringthe text to insert.

Return

FlexTable — the FlexTable itself, useful for chaining.


setTitle(title)

Sets the hover title of this FlexTable.

Not all browsers will show this.

Parameters

NameTypeDescription
titleStringthe hover title.

Return

FlexTable — the FlexTable itself, useful for chaining.


setVisible(visible)

Sets whether this FlexTable is visible.

Parameters

NameTypeDescription
visibleBooleanwhether this FlexTable should be visible or not.

Return

FlexTable — the FlexTable itself, useful for chaining.


setWidget(row, column, widget)

Sets the widget in a given cell. A cell can contain at most one widget.

Parameters

NameTypeDescription
rowIntegerthe row of the cell.
columnIntegerthe column of the cell.
widgetWidgetthe widget to insert.

Return

FlexTable — the FlexTable itself, useful for chaining.


setWidth(width)

Sets the width of this FlexTable.

Parameters

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

Return

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