The tables
interface acts as a parent to the tables in the form. You can access individual tables using tables.myTable
.
Common actions to perform include:
- Inserting new rows -
tables.myTable.insertRow();
- Fetching table data from a Resource -
tables.myTable.fetchTable(noUpdate);
- Update table data to a Resource -
tables.myTable.updateTable();
Note that the fetchTable
operation has a Boolean parameter, noUpdate
. This parameter should be set to true
when no updateTable
operations will be performed (e.g. when data is only displayed) as it allows memory-saving techniques to be used.
You can access individual columns using tables.myTable.myColumn
. This interface can be used to access or update the value of a column on the current row, e.g. tables.myTable.myColumn.value
. This is also accessible via the getValue()
and setValue()
functions.
To access other rows you can set the current row (e.g. tables.myTable.setCurrentRow(rowNumber)
) or loop through the Table Rows.
The getColumns()
function retrieves an array of Column Controls for a table. By iterating through this array it is possible to perform operations on, or manipulate the data contained by, all the columns in a table.
// Get an array of columns for myTable
var cols = tables.myTable.getColumns();
// For each column in the table, log the label
cols.forEach(function(col) {
log(col.getLabelText());
});
The interface also allows you to access Table Controls or Repeater Controls backed by the table. The first control for a given table can be retrieved using the getControl(pageName)
function, optionally for a specified page (rather than the current page). An example is given below:
// Retrieve the 1st Table Control, or Repeater Control, for myTable
var myTableControl = tables.myTable.getControl();
// Do something with the control, such as hiding it
myTableControl.hide();