createTable()
The createTable() function (client-side and server-side) creates a script-generated table using the table code. If you pass the code of an existing table, the function returns it as a table object using getTable().
Syntax
Use this syntax for the createTable() function:
createTable('TABLE_CODE');
Return Value
The createTable() function returns an object. This object includes the tableRef property, which contains information about the table record:
-
id -
code -
type -
status -
content
The returned object also provides methods for setting, retrieving, and updating table data, as well as changing the table status and loading content. The following table outlines the methods provided by the returned object.
|
Method |
Description |
|---|---|
|
|
Updates the entire table content. |
|
|
Sets the values for an entire row. |
|
|
Sets the value of a specific cell. |
|
|
Returns the entire table content as an array of rows. |
|
|
Returns the entire row. |
|
|
Returns the value of a cell. |
|
|
Imports data from an object into a two-column table using key-value mappings. The
|
|
|
Changes the table status. The available statuses are |
|
Note:
This method is available for dynamic tables only. Loads table content from the database. This method returns a promise that resolves to an object containing the table content. The |
Parameters
The createTable() function accepts the table code in string format ('TABLE_CODE') as a required parameter. For existing tables, you can find the code in the Code field on the table record.
Examples
The following examples show how to use the createTable() function.
Retrieving or Creating a Table
This example calls createTable() to retrieve a table with the code LAPTOPS. If the table doesn't exist, the function will create it.
const laptopsTable = createTable('LAPTOPS');