Interface Table
- All Superinterfaces:
Element
,java.io.Serializable
- All Known Subinterfaces:
WebFormTable
public interface Table extends Element
Table
interface represents a table defined in a form, integration service or workflow job.
Individual tables can be accessed via the Tables
interface.
- Since:
- V4.4
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SORT_DIRECTION_ASCENDING
A constant for sort direction ascending for use with the sort() methodsstatic java.lang.String
SORT_DIRECTION_DESCENDING
A constant for sort direction descending for use with the sort() methods -
Method Summary
Modifier and Type Method Description void
copyTable(Table fromTable, boolean removeExistingRows)
Optionally removes all existing rows and then copies rows from the table specified byfromTable
.boolean
deleteRow()
Deletes the current row (seegetCurrentRow()
) in the table.boolean
deleteRow(int row)
Deletes the specified row in the table.TableRowIterator
fetchTable()
Loads data into the table from the external resource specified as the backing resource, and sets the first row as the current row (seegetCurrentRow()
).TableRowIterator
fetchTable(boolean noUpdate)
Loads data into the table from the external resource specified as the backing resource, and sets the first row as the current row (seegetCurrentRow()
).int
findRow(TableColumn column, java.lang.Object value)
Returns the first row number with the specified column value, or -1 if no match is found.TableRowIterator
findRows(java.util.Map<java.lang.String,java.lang.Object> parms)
Returns a row iterator object containing all rows that match the search criteria specified byparms
.TableColumn
getColumn(java.lang.String columnName)
Returns the specified table column or null if the column does not exist.TableColumn[]
getColumns()
Returns an array of all columns in the table.java.lang.Object
getColumnValueOnRow(TableColumn column, int row)
Returns anObject
representing the value of the table cell at the specified column and row.int
getCurrentRow()
Returns the row number for the table's current row.int
getRowCount()
Returns the number of rows in the table.TableRowIterator
getRows()
Returns a row iterator object that can be used to traverse all table rowsTableColumn[]
getSortColumns()
Returns anArray
of all the columns that are currently sorted.java.lang.String[]
getSortDirections()
Returns anArray
of all the directions that are currently sorted.int
insertRow()
Inserts a new row into the table and sets this row as the current row of the table (seegetCurrentRow()
).boolean
isRowDeletedByUser()
Returns true if the current row (seegetCurrentRow()
) is marked as deleted by the user.boolean
isRowDeletedByUser(int row)
Returns true if the specified row is marked as deleted by the user.boolean
isRowEmpty()
Returns true if the current row (seegetCurrentRow()
) is marked as empty.boolean
isRowEmpty(int row)
Returns true if the specified row is marked as empty.boolean
isRowInserted()
Returns true if the current row (seegetCurrentRow()
) has been inserted.boolean
isRowInserted(int row)
Returns true if the specified row has been inserted.boolean
isRowModified()
Returns true if the current row (seegetCurrentRow()
) has been modified.boolean
isRowModified(int row)
Returns true if the specified row has been modified.boolean
isRowSelected()
Returns true if the current row (seegetCurrentRow()
) is marked as selectedboolean
isRowSelected(int row)
Returns true if the specified row is marked as selected.void
loadFromJSON(java.lang.String jsonString)
Loads rows from a JSON string into the table.void
replaceTable(Table fromTable)
Removes all existing rows and copies rows from the table specified byfromTable
.void
resetTable()
Removes all rows from the table and resets the current row (seegetCurrentRow()
).void
setColumnValueOnRow(TableColumn column, int row, java.lang.Object value)
Sets a value for the table cell at the specified column and row.void
setCurrentRow(int row)
Sets the table's current row.void
setRowDeletedByUser(boolean deleted)
Sets the deleted by the user status for the current row (seegetCurrentRow()
).void
setRowDeletedByUser(int row, boolean deleted)
Sets the deleted by the user status for the specified row.void
setRowEmpty(boolean empty)
Sets the empty status for the current row (seegetCurrentRow()
).void
setRowEmpty(int row, boolean empty)
Sets the empty status for the specified row.void
setRowSelected(boolean selected)
Sets the selected flag for the current row (seegetCurrentRow()
).void
setRowSelected(int row, boolean selected)
Sets the selected flag for the specified row.void
sort(TableColumn column)
Sorts the table rows using the single column specified bycolumn
in ascending order.void
sort(TableColumn[] columns)
Sorts the table rows using multiple columns in ascending order.void
sort(TableColumn[] columns, java.lang.String[] directions)
Sorts the table rows using multiple columns.void
sort(TableColumn column, java.lang.String direction)
Sorts the table rows using the single column specified bycolumn
in the order specified bydirection
.java.lang.String
toJSON()
Returns a JSON string representing all rows in the table in the following format:java.lang.String
toJSON(boolean excludeNullValues)
Returns a JSON string representing all rows in the table, this is the same astoJSON()
but additionally provides an option on how null values in table columns are handled.void
updateTable()
Updates the external resource specified as the backing resource for the table with the table data, deleting, inserting, and updating rows as required.Methods inherited from interface com.ebasetech.xi.api.Element
getElementName, getElementType
-
Field Details
-
SORT_DIRECTION_ASCENDING
static final java.lang.String SORT_DIRECTION_ASCENDINGA constant for sort direction ascending for use with the sort() methods- See Also:
- Constant Field Values
-
SORT_DIRECTION_DESCENDING
static final java.lang.String SORT_DIRECTION_DESCENDINGA constant for sort direction descending for use with the sort() methods- See Also:
- Constant Field Values
-
-
Method Details
-
fetchTable
Loads data into the table from the external resource specified as the backing resource, and sets the first row as the current row (seegetCurrentRow()
). All internal row numbers are reset.Javascript example:
var orders = tables.ORDERS; var rows = orders.fetchTable(); while (rows.next()) { orders.ORDER_VAT.value = orders.ORDER_VALUE.value * vatRate; }
- Returns:
- a row iterator object that can be used to traverse all table rows
- Throws:
com.ebasetech.xi.exceptions.FormRuntimeException
- Since:
- V4.4
- See Also:
updateTable()
-
fetchTable
TableRowIterator fetchTable(boolean noUpdate) throws com.ebasetech.xi.exceptions.FormRuntimeExceptionLoads data into the table from the external resource specified as the backing resource, and sets the first row as the current row (seegetCurrentRow()
). All internal row numbers are reset.The
noUpdate
flag provides an optional optimization. When this flag is set to true, the amount of memory required to support the table content data is reduced by about 50%; however, it is not possible to use theupdateTable()
method. It is recommended that this option should be used for all read only tables.Javascript example:
var orders = tables.ORDERS; var rows = orders.fetchTable(true); while (rows.next()) { orders.ORDER_VAT.value = orders.ORDER_VALUE.value * vatRate; }
- Parameters:
noUpdate
- when true indicates that the table will not be updated withupdateTable()
- Returns:
- a row iterator object that can be used to traverse all table rows
- Throws:
com.ebasetech.xi.exceptions.FormRuntimeException
- Since:
- V4.4
- See Also:
updateTable()
-
updateTable
void updateTable() throws com.ebasetech.xi.exceptions.FormRuntimeExceptionUpdates the external resource specified as the backing resource for the table with the table data, deleting, inserting, and updating rows as required. Any rows flagged as empty are ignored and are not written to the external resource. All internal row numbers are reset. The current row (seegetCurrentRow()
) may be changed by this command.Javascript example:
tables.ORDERS.updateTable();
- Throws:
com.ebasetech.xi.exceptions.FormRuntimeException
- Since:
- V4.4
- See Also:
fetchTable()
-
replaceTable
Removes all existing rows and copies rows from the table specified byfromTable
. This method is equivalent to callingcopyTable(fromTable, true)
. Rows flagged as empty infromTable
are ignored. Any rows infromTable
that have been deleted using thedeleteRow()
method are ignored. All other rows are copied.All columns having the same name in each table are copied e.g. if T1 has columns A, B, C, D and T2 has columns B, C, X, Y,
T1.replaceTable(T2)
will result in data from columns B and C being copied. Any other columns in T1 will be set to null or the column's default value. The current row (seegetCurrentRow()
) is set to the first row after the copy.The table specified by
fromTable
is unaffected and is not changed in any way.Javascript example:
tables.ORDERS.replaceTable(tables.ORDERS_SAVE);
- Parameters:
fromTable
- the source table from which rows are copied- Throws:
com.ebasetech.xi.exceptions.FormRuntimeException
- Since:
- V4.4
- See Also:
fetchTable()
-
copyTable
void copyTable(Table fromTable, boolean removeExistingRows) throws com.ebasetech.xi.exceptions.FormRuntimeExceptionOptionally removes all existing rows and then copies rows from the table specified byfromTable
. Rows flagged as empty infromTable
are ignored. Any rows infromTable
that have been deleted using thedeleteRow()
method are ignored. All other rows are copied.All columns having the same name in each table are copied e.g. if T1 has columns A, B, C, D and T2 has columns B, C, X, Y,
T1.copyTable(T2, true)
will result in data from columns B and C being copied. Any other columns in T1 will be set to null or the column's default value. The current row (seegetCurrentRow()
) is set to the first row after the copy.The table specified by
fromTable
is unaffected and is not changed in any way.Javascript example:
tables.ORDERS.copyTable(tables.ORDERS_SAVE, false);
- Parameters:
fromTable
- the source table from which rows are copiedremoveExistingRows
- if true, all existing rows are removed from the table prior to copying- Throws:
com.ebasetech.xi.exceptions.FormRuntimeException
- Since:
- V4.4
- See Also:
fetchTable()
-
resetTable
void resetTable()Removes all rows from the table and resets the current row (seegetCurrentRow()
).Javascript example:
tables.ORDERS.resetTable();
Note that resetTable() will not result in the deletion of records from a backing resource specified for the table e.g. a Database Resource. i.e. any subsequentupdateTable()
method will not remove these rows from the attached resource. To remove all rows from the table and the backing resource use:var t1 = tables.MyTable; var rows = t1.rows; while (rows.next()) { t1.deleteRow(); } t1.updateTable();
- Since:
- V4.4
- See Also:
replaceTable(Table)
,updateTable()
-
getRows
TableRowIterator getRows()Returns a row iterator object that can be used to traverse all table rowsJavascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { orders.ORDER_VAT.value = orders.ORDER_VALUE.value * vatRate; }
- Returns:
- a row iterator object that can be used to traverse all table rows
- Since:
- V4.4
- See Also:
fetchTable()
-
getRowCount
int getRowCount()Returns the number of rows in the table.- Returns:
- the number of rows in the table
- Since:
- V4.4
- See Also:
fetchTable()
-
getColumn
Returns the specified table column or null if the column does not exist. WhencolumnName
is a valid Java name, the column can more easily be accessed astableName.columnName
e.g.T1.COL1
, however use of this method is the only way to access column names that are not valid Java names.Javascript example:
var col = tables.ORDERS.getColumn("2XX");
- Returns:
- a table column, or null if the column does not exist
- Since:
- V4.4
-
getColumns
TableColumn[] getColumns()Returns an array of all columns in the table.Javascript example:
var cols = tables.ORDERS.getColumns(); for each (var col in cols) { log(col.elementName + ": " + col.value); }
- Returns:
- an array of all columns in the table
- Since:
- V4.4
-
deleteRow
boolean deleteRow()Deletes the current row (seegetCurrentRow()
) in the table.When the table is backed by an external resource such as a database, the row will be deleted from this resource when a subsequent
updateTable()
method is invoked.Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { if (shouldDeleteOrder()) { orders.deleteRow(); } }
- Returns:
- true if the row has been deleted which should always be the case
- Since:
- V4.4
-
isRowSelected
boolean isRowSelected()Returns true if the current row (seegetCurrentRow()
) is marked as selectedA row can be marked as selected by:
- using the
setRowSelected(boolean)
orsetRowSelected(int, boolean)
method - by the user when a select column checkbox is included within a Table Control
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { if (orders.isRowSelected()) { .. } }
- Returns:
- true if the row has been selected
- Since:
- V4.4
- using the
-
isRowDeletedByUser
boolean isRowDeletedByUser()Returns true if the current row (seegetCurrentRow()
) is marked as deleted by the user.A row can be marked as deleted by the user by:
- using the
setRowDeletedByUser(boolean)
orsetRowDeletedByUser(int, boolean)
method - by the user when a delete column checkbox is included within a Table Control
deleteRow()
ordeleteRow(int)
methods are not marked as deleted by the user.Note that the deleted by the user status is removed when
updateTable()
is called.Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { if (orders.isRowDeletedByUser()) { .. } }
- Returns:
- true if the row has been marked as deleted by the user
- Since:
- V4.4
- using the
-
isRowInserted
boolean isRowInserted()Returns true if the current row (seegetCurrentRow()
) has been inserted. Note that the inserted status is removed whenupdateTable()
is called.Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { if (orders.isRowInserted()) { .. } }
- Returns:
- true if the row has been inserted
- Since:
- V4.4
-
isRowEmpty
boolean isRowEmpty()Returns true if the current row (seegetCurrentRow()
) is marked as empty.A row is marked as empty when:
- the row is added by the user clicking on the add row button of a Table Control and none of the columns have a value
- method
setRowEmpty(boolean)
orsetRowEmpty(int, boolean)
is called
updateTable()
method.Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { if (orders.isRowEmpty()) { .. } }
- Returns:
- true if the row is marked as empty
- Since:
- V4.4
-
isRowModified
boolean isRowModified()Returns true if the current row (seegetCurrentRow()
) has been modified. Note that inserted or deleted rows will always return false.Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { if (orders.isRowModified()) { .. } }
- Returns:
- true if the row has been modified
- Since:
- V4.4
-
deleteRow
boolean deleteRow(int row)Deletes the specified row in the table.When the table is backed by an external resource such as a database, the row will be deleted from this resource when a subsequent
updateTable()
method is invoked.Javascript example:
var deleted = tables.ORDERS.deleteRow(rowNum);
- Parameters:
row
- number- Returns:
- true if the row has been deleted, false if the row does not exist
- Since:
- V4.4
-
isRowSelected
boolean isRowSelected(int row)Returns true if the specified row is marked as selected. Throws anIllegalArgumentException
ifrow
is not a valid row number.A row can be marked as selected by:
- using the
setRowSelected(boolean)
orsetRowSelected(int, boolean)
method - by the user when a select column checkbox is included within a Table Control
Javascript example:
if (tables.ORDERS.isRowSelected(rowNum)) { .. }
- Parameters:
row
- number- Returns:
- true if the row has been selected
- Since:
- V4.4
- using the
-
isRowDeletedByUser
boolean isRowDeletedByUser(int row)Returns true if the specified row is marked as deleted by the user. Throws anIllegalArgumentException
ifrow
is not a valid row number.A row can be marked as deleted by the user by:
- using the
setRowDeletedByUser(boolean)
orsetRowDeletedByUser(int, boolean)
method - by the user when a delete column checkbox is included within a Table Control
deleteRow()
ordeleteRow(int)
methods are not marked as deleted by the user.Note that the deleted by the user status is removed when
updateTable()
is called.Javascript example:
if (tables.ORDERS.isRowDeletedByUser(rowNum)) { .. }
- Parameters:
row
- number- Returns:
- true if the row has been marked as deleted by the user
- Since:
- V4.4
- using the
-
isRowInserted
boolean isRowInserted(int row)Returns true if the specified row has been inserted. Throws anIllegalArgumentException
ifrow
is not a valid row number. Note that the inserted status is removed whenupdateTable()
is called.Javascript example:
if (orders.isRowInserted(rowNum)) { .. }
- Parameters:
row
- number- Returns:
- true if the row has been inserted
- Since:
- V4.4
-
isRowEmpty
boolean isRowEmpty(int row)Returns true if the specified row is marked as empty. Throws anIllegalArgumentException
ifrow
is not a valid row number.A row is marked as empty when:
- the row is added by the user clicking on the add row button of a Table Control and none of the columns have a value
- method
setRowEmpty(boolean)
orsetRowEmpty(int, boolean)
is called
updateTable()
method.Javascript example:
if (orders.isRowEmpty(rowNum)) { .. }
- Parameters:
row
- number- Returns:
- true if the row is marked as empty
- Since:
- V4.4
- See Also:
updateTable()
-
isRowModified
boolean isRowModified(int row)Returns true if the specified row has been modified. Throws anIllegalArgumentException
ifrow
is not a valid row number. Note that inserted or deleted rows will always return false.Javascript example:
if (orders.isRowModified(rowNum)) { .. }
- Parameters:
row
- number- Returns:
- true if the row has been modified
- Since:
- V4.4
-
setRowSelected
void setRowSelected(boolean selected)Sets the selected flag for the current row (seegetCurrentRow()
).The selected status can be displayed to the user by adding a select column checkbox to a Table Control.
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { orders.setRowSelected(false); }
- Parameters:
selected
-- Since:
- V4.4
- See Also:
isRowSelected()
-
setRowSelected
void setRowSelected(int row, boolean selected)Sets the selected flag for the specified row. Throws anIllegalArgumentException
ifrow
is not a valid row number.The selected status can be displayed to the user by adding a select column checkbox to a Table Control.
Javascript example:
tables.ORDERS.setRowSelected(rowNum, false);
- Parameters:
row
- numberselected
-- Since:
- V4.4
- See Also:
isRowSelected(int)
-
setRowDeletedByUser
void setRowDeletedByUser(boolean deleted)Sets the deleted by the user status for the current row (seegetCurrentRow()
). Note that the deleted by the user status is removed whenupdateTable()
is called.The deleted by the user status can be displayed to the user by adding a delete column checkbox to a Table Control.
Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { orders.setRowDeletedByUser(false); }
- Parameters:
deleted
-- Since:
- V4.4
- See Also:
isRowDeletedByUser()
-
setRowDeletedByUser
void setRowDeletedByUser(int row, boolean deleted)Sets the deleted by the user status for the specified row. Throws anIllegalArgumentException
ifrow
is not a valid row number. Note that the deleted by the user status is removed whenupdateTable()
is called.The deleted by the user status can be displayed to the user by adding a delete column checkbox to a Table Control.
Javascript example:
tables.ORDERS.setRowDeletedByUser(rowNum, false);
- Parameters:
row
- numberdeleted
-- Since:
- V4.4
- See Also:
isRowDeletedByUser(int)
-
setRowEmpty
void setRowEmpty(boolean empty)Sets the empty status for the current row (seegetCurrentRow()
). Rows marked as empty are ignored by theupdateTable()
method.Javascript example:
var orders = tables.ORDERS; var rows = orders.getRows(); while (rows.next()) { orders.setRowEmpty(false); }
- Parameters:
empty
-- Since:
- V4.4
- See Also:
isRowEmpty()
-
setRowEmpty
void setRowEmpty(int row, boolean empty)Sets the empty status for the specified row. Rows marked as empty are ignored by theupdateTable()
method. Throws anIllegalArgumentException
ifrow
is not a valid row number.Javascript example:
tables.ORDERS.setRowEmpty(rowNum, false);
- Parameters:
row
- numberempty
-- Since:
- V4.4
- See Also:
isRowEmpty(int)
-
insertRow
int insertRow()Inserts a new row into the table and sets this row as the current row of the table (seegetCurrentRow()
). The columns in the row are initialized with their default values or null as appropriate. Inserted rows are displayed at the bottom of a Table Control.Javascript example:
var newRowNum = tables.ORDERS.insertRow();
- Returns:
- the row number of the new row
- Since:
- V4.4
-
findRow
Returns the first row number with the specified column value, or -1 if no match is found.Javascript example:
var row = tables.ORDERS.findRow(tables.ORDERS.ORDER_ID, fields.SEARCH_ORDER_ID.value); if (row != -1) { tables.ORDERS.setCurrentRow(row); }
- Parameters:
column
- table columnvalue
- the value of the table column, should be the same type as the underlying column object (seeField.getValue()
)- Returns:
- the row number of the found row or -1
- Since:
- V4.4
- See Also:
findRows(Map)
-
findRows
Returns a row iterator object containing all rows that match the search criteria specified byparms
.Javascript example:
var searchParms = {}; searchParms.CUSTOMER_TYPE = "Internal"; searchParms.RATING = 4; var rows = tables.CUSTOMERS.findRows(searchParms); while (rows.next()) { .. }
- Parameters:
parms
- a Map of key/value pairs where key is a column name and value is the corresponding value. In Javascript, an Object can be used where key is a column name and value is the corresponding value which should be the same type as the underlying column object (seeField.getValue()
).- Returns:
- a table row iterator
- Since:
- V4.4
- See Also:
findRow(TableColumn, Object)
-
getCurrentRow
int getCurrentRow()Returns the row number for the table's current row.The current row represents an important concept - a current row exists for all tables that are not empty. All references to table columns and their values which do not explicitly specify a row number are interpreted as referring to the corresponding table cell for the column on the current row. For example, in the following line of code, values for the
ORDER_VAT
andORDER_VALUE
columns are obtained from the current row.orders.ORDER_VAT.value = orders.ORDER_VALUE.value * vatRate;
The current row is set by the system as follows:- when a table cell event is executed e.g. user clicks a button or hyperlink, the current row is set to the row containing that table cell
- while traversing table rows using a
TableRowIterator
, the current row is set each time thenext()
orprevious()
method is invoked. When all rows have been processed by theTableRowIterator
, the current row is returned to its original value. If all rows are not processed by theTableRowIterator
, the current row remains set to the row at the break point. - the
insertRow()
method, or the user clicking the add row button, both set the current row to the new row - the
fetchTable()
method sets the first row as the current row - a sort operation, either invoked by the user or using one of the
sort(TableColumn)
methods, sets the first row as the current row - the
updateTable()
may reset the current row depending on circumstances - a vertical scroll operation by the user sets the current row to the first visible row of the new display
- Returns:
- the row number of the table's current row
- Since:
- V4.4
-
setCurrentRow
void setCurrentRow(int row)Sets the table's current row.- Since:
- V4.4
- See Also:
getCurrentRow()
-
sort
Sorts the table rows using multiple columns. Columns are processed from left to right.Javascript example:
tables.ORDERS.sort( [tables.ORDERS.DELIVERY_DATE, tables.ORDERS.QUANTITY], [Table.SORT_DIRECTION_DESCENDING, Table.SORT_DIRECTION_ASCENDING] );
- Parameters:
columns
- an array of table columnsdirections
- an array of directions where each direction is either "asc" or "desc" (static constantsTable.SORT_DIRECTION_ASCENDING
orTable.SORT_DIRECTION_DESCENDING
can be used). The sort direction at position n is applied to the column at position n. The number of directions must match the number of columns.- Since:
- V4.4
-
sort
Sorts the table rows using multiple columns in ascending order. Columns are processed from left to right.Javascript example:
tables.ORDERS.sort( [tables.ORDERS.DELIVERY_DATE, tables.ORDERS.QUANTITY] );
- Parameters:
columns
- an array of table columns- Since:
- V4.4
-
sort
Sorts the table rows using the single column specified bycolumn
in the order specified bydirection
.Javascript example:
tables.ORDERS.sort(tables.ORDERS.DELIVERY_DATE, Table.SORT_DIRECTION_DESCENDING);
- Parameters:
column
- the table columndirection
- either "asc" or "desc" (static constantsTable.SORT_DIRECTION_ASCENDING
andTable.SORT_DIRECTION_DESCENDING
can be used)- Since:
- V4.4
-
sort
Sorts the table rows using the single column specified bycolumn
in ascending order.Javascript example:
tables.ORDERS.sort(tables.ORDERS.DELIVERY_DATE);
- Parameters:
column
- the table column- Since:
- V4.4
-
getColumnValueOnRow
Returns anObject
representing the value of the table cell at the specified column and row. SeeField.getValue()
for documentation on which object types are returned for each column type.Javascript examples:
tables.ORDERS.getColumnValueOnRow(tables.ORDERS.ORDER_VALUE, rowNum);
- Parameters:
column
- the table columnrow
- row number- Since:
- V4.4
- See Also:
Field.getValue()
-
setColumnValueOnRow
Sets a value for the table cell at the specified column and row. SeeField.setValue(Object)
for documentation on which object types can be used with each column type.Javascript examples:
tables.ORDERS.setColumnValueOnRow(tables.ORDERS.ORDER_VALUE, rowNum, 25.13);
- Parameters:
column
- the table columnrow
- row numbervalue
- the value object, seeField.setValue(Object)
- Since:
- V4.4
-
getSortColumns
TableColumn[] getSortColumns()Returns anArray
of all the columns that are currently sorted. This can be useful to reestablish a sort order created by the user after a fetchtable.See
getSortDirections()
for documentation on sort directions
Seesort(TableColumn[])
for documentation on sorting columnsJavascript examples:
var sortColumns = tables.ORDERS.getSortColumns(); var sortDirections = tables.ORDERS.getSortDirections(); tables.ORDERS.fetchTable(); tables.ORDERS.sort(sortColumns, sortDirections);
- Since:
- V5.0
- See Also:
getSortDirections()
,sort(TableColumn[], String[])
-
getSortDirections
java.lang.String[] getSortDirections()Returns anArray
of all the directions that are currently sorted. The position of the sort in theArray
matches the position of the column name within theArray
returned fromgetSortColumns()
. This can be useful to reestablish a sort order created by the user after a fetchtable.The sort order directions are defined as
SORT_DIRECTION_ASCENDING
orSORT_DIRECTION_DESCENDING
.See
getSortDirections()
for documentation on sort directions
Seesort(TableColumn[], String[])
for documentation on sorting columnsJavascript examples:
var sortColumns = tables.ORDERS.getSortColumns(); var sortDirections = tables.ORDERS.getSortDirections(); tables.ORDERS.fetchTable(); tables.ORDERS.sort(sortColumns, sortDirections);
- Since:
- V5.0
- See Also:
getSortColumns()
,sort(TableColumn[], String[])
-
toJSON
java.lang.String toJSON()Returns a JSON string representing all rows in the table in the following format:{ rows: [ {Name:Smith, Age:31, StartDate:1459206000000}, {Name:Mendez, Age:23, StartDate:1462306000000}, {Name:Jones, Age:45, StartDate:1459961000000} ] }
The JSON string contains a single "rows" property which contains an array of table rows where each row contains columnName:value property pairs where the value for each column is the same as its value property, seeField.getValue()
. Columns with null values are included with an explicit "null" value. SeetoJSON(boolean)
which includes an option to exclude columns with a null value.Examples:
// 1. send to REST web service var ordersJson = tables.ORDERS.toJSON(); services.rest.put("http://example.com/rest/orders", ordersJson); // 2. convert to Javascript object var ordersJson = tables.ORDERS.toJSON(); var ordersObj = JSON.parse(ordersJson); var order1Value = ordersObj.rows[0].orderValue; var order2Id = ordersObj.rows[1].orderId; for each (var order in ordersObj.rows) { var id = order.orderId; var orderDate = order.orderDate; }
- Since:
- V5.1
- See Also:
toJSON(boolean)
,loadFromJSON(String)
-
toJSON
java.lang.String toJSON(boolean excludeNullValues)Returns a JSON string representing all rows in the table, this is the same astoJSON()
but additionally provides an option on how null values in table columns are handled. Columns with a null value can either be omitted or included as value "null".{ rows: [ {Name:Smith, Age:31, StartDate:1459206000000}, {Name:Mendez, Age:23, StartDate:1462306000000}, {Name:Jones, Age:null, StartDate:null} ] }
The JSON string contains a single "rows" property which contains an array of table rows where each row contains columnName:value property pairs where the value for each column is the same as its value property, seeField.getValue()
. whenexcludeNullValues
is true, columns with null values are omitted. WhenexcludeNullValues
is false, columns with null values are included with value "null" - see example above;Examples:
// 1. send to REST web service var ordersJson = tables.ORDERS.toJSON(true); services.rest.put("http://example.com/rest/orders", ordersJson); // 2. convert to Javascript object var ordersJson = tables.ORDERS.toJSON(true); var ordersObj = JSON.parse(ordersJson); var order1Value = ordersObj.rows[0].orderValue; var order2Id = ordersObj.rows[1].orderId; for each (var order in ordersObj.rows) { var id = order.orderId; var orderDate = order.orderDate; }
- Parameters:
excludeNullValues
- when true, columns with null values are omitted; when false, columns with null values are included with value "null"- Since:
- V5.1
- See Also:
toJSON()
,loadFromJSON(String)
-
loadFromJSON
void loadFromJSON(java.lang.String jsonString)Loads rows from a JSON string into the table. The JSON string must be formatted as per the following example (which is split into multiple rows for clarity):"{ rows: [ {Name:Smith, Age:31, StartDate:1459206000000}, {Name:Mendez, Age:23, StartDate:1462306000000}, {Name:Jones, Age:45, StartDate: null} ] }"
This represents a Javascript object with a single "rows" property which contains an array of table rows where each row contains columnName:value property pairs. Any value that can be specified for a column's value property can be used, seeField.setValue(Object)
. Columns with null values can be either excluded completely or "null" can be specified as the column value as per the example above. ThetoJSON()
methods can be used to generate a JSON string with this format from an existing table.This method does not delete any existing rows that might exist in the table. If this is required
resetTable()
should be called first.Examples:
var jsonString = "{rows:[{Name:Smith, Age:31, StartDate:1459206000000}, {Name:Mendez, Age:23, StartDate:1462306000000}]}" tables.ORDERS.loadFromJSON(jsonString); tables.ORDERS.control.scrollToTop(); //scroll to the top of the table
- Parameters:
jsonString
- formatted JSON string containing table row data- Since:
- V5.1
- See Also:
toJSON()
,toJSON(boolean)
-