CodeAPI

TableCellEvent

Event that is fired when a table cell is selected.

This event is only fired if the table is set in the Editor to select cells when clicked.

Table of Contents

PROPERTIES

?
Store values associated with an object.
cellColumnIdGets the column ID of the selected cell.
cellDataGets the data from the selected cell.
cellRowIndexGets the row index of the selected cell.
contextGets the context of the event on a repeated element.
targetGets the element that the event was fired on.
typeGets the type of event that was fired.

MIXES IN

?
Where some functionality is inherited from.
$w.Event

cellColumnId

Gets the column ID of the selected cell.

Description

The cellColumnId is the id property of the Column object that corresponds to the column of the selected cell.

Syntax

get cellColumnId(): string
TYPE
?
The kind of data the property stores.
string

Examples

Get the selected table cell information

$w("#myTable").onCellSelect( (event) => {
  let cellColId = event.cellColumnId;     // "columnId_b2b3-87d9-49250"
  let cellData = event.cellData;          // "John"
  let cellRowIndex = event.cellRowIndex;  // 1
} );

cellData

Gets the data from the selected cell.

Syntax

get cellData(): string
TYPE
?
The kind of data the property stores.
string

Examples

Get the selected table cell information

$w("#myTable").onCellSelect( (event) => {
  let cellColId = event.cellColumnId;     // "columnId_b2b3-87d9-49250"
  let cellData = event.cellData;          // "John"
  let cellRowIndex = event.cellRowIndex;  // 1
} );

cellRowIndex

Gets the row index of the selected cell.

Description

The rows in a table are zero-based and do not include the table header.

Syntax

get cellRowIndex(): number
TYPE
?
The kind of data the property stores.
number

Examples

Get the selected table cell information

$w("#myTable").onCellSelect( (event) => {
  let cellColId = event.cellColumnId;     // "columnId_b2b3-87d9-49250"
  let cellData = event.cellData;          // "John"
  let cellRowIndex = event.cellRowIndex;  // 1
} );

context

Gets the context of the event on a repeated element.

Description

An event's context contains information about the circumstances surrounding the firing of the event. The context property only appears in events on repeated elements.

You can use the evnet context with $w.at() to get a selector function which selects items from a specific repeater item. It contains an object with one key:value pair. The key is "itemId" and the value is the ID of the repeated item on which the event occurred.

Syntax

get context(): EventContext

MIXED IN FROM

?
Where this functionality is inherited from.
$w.Event

Examples

Get the context of the event

// non-repeater event

$w("#myElement").onEvent( (event) => {
  let type = event.context.type; // "GLOBAL_SCOPE"
} );


// repeater event

$w("#myRepeatedElement").onEvent( (event) => {
  let $item = $w.at(event.context)
  $item("#anotherRepeatedElement").value = "new value";

  let itemId = event.context.itemId;  // "item1"
} );

target

Gets the element that the event was fired on.

Note

When using the target to get the value of a text input or text box in an onKeyPress event handler, you may receive the value of the element before the key was pressed. To get the text input or text box's updated value, use the updatedTargetValue property of the event handler's event parameter.

Syntax

get target(): Element
TYPE
?
The kind of data the property stores.

MIXED IN FROM

?
Where this functionality is inherited from.
$w.Event

Examples

Get the ID of the target element

$w("#myElement").onEvent( (event) => {
  let targetId = event.target.id;  // "myElement"
} );

type

Gets the type of event that was fired.

Syntax

get type(): string
TYPE
?
The kind of data the property stores.
string

MIXED IN FROM

?
Where this functionality is inherited from.
$w.Event

Examples

Get the type of the event

$w("#myElement").onEvent( (event) => {
  let eventType = event.type; // "click"
} );