Constructor
new Table(textopt)
Create Table UI component.
| Name | Type | Attributes | Description |
|---|---|---|---|
text | String | <optional> | Text value held by the component. It can be used as a Tab text when the Table is added to Tabs component. |
<h2>Format of a column object:</h2>
{
text: string, // (Required) The text to be displayed in the column header.
type: string, // Type of component to use to display/edit cell data. Here is a list of possible types:
// "text" (Default) - Plain text or HTML. WARNING: Images in HTML content get loaded from source each time they are drawn, so loading images from the web is discouraged.
// "password" - A masked password text field.
// "textarea" - A multi-line text field.
// "icon" - Image loaded from a cell value source (relative/absolute local path or URL). To receive click events register callback using table.onAction(callback); e.type will be "button".
// "button" - String of button names separated by "|" character. To receive click events register callback using table.onAction(callback); e.type will be "icon".
// "checkbox" - `true` and `false` value selection component using a check mark.
// "combobox" - A drop down list of values. Can be editable to add custom value.
// "progress" - A progress bar that visually displays an integer cell value between 0 and 100.
sorting: Table.Sorting, // Table.Sorting.None disables sorting for the given column, other values of Table.Sorting specify the type of sorting to use. Table.Sorting.Natural is default.
icon_size: number, // For "icon" column type it specifies the fixed height of width of the icon (which ever is larger), resizing it while maintaining aspect ratio.
cache_capacity: number, // For "icon" column type it specifies the amount of images cached in RAM so they don't have to be loaded from source each time they are drawn on the screen. Default is 10.
resizable: boolean, // Indicates whether user should be able resize the column.
auto_resize: boolean, // indicates if this column should be auto-resized when table is resized. Note that this is ignored when table's auto resize is set to Table.AutoResize.None.
width: number, // Sets a desired initial width of the column.
min_width: number, // Sets a minimum width that the column can be resized to.
max_width: number, // Sets a maximum width that the column can be resized to.
hidden: boolean, // When set to `true`, the column is not visible (width is 0 pixels). To show hidden column set this property to `false`. Default is `false`.
character: string, // For column type "password" it sets a text character to use as a masking character.
editable: boolean, // Sets whether text fields should be editable (usually by double clicking on them).
clicksToEdit: boolean, // Specifies after how many quick clicks on text editing cells they become editable (For example 1, 2, or 3). Only has affect if the column is editable.
options: string[] // For "combobox" type of column specifies a list of values to show in the combobox list.
}
// NOTE: When adding a new column, only "text" is required for the column, other properties are optional.Classes
Members
(readonly) AutoResize :number
Enum for table column auto-resizing modes. Used with Table#autoResizeColumns.
- number
| Name | Type | Description |
|---|---|---|
None | number | Do not auto-resize columns when one of the columns is resized. |
NextColumn | number | Resize the next column when current column changes. |
SubsequentColumns | number | Resize all columns to the right of the changed column. |
LastColumn | number | Resize only the last column. |
AllColumns | number | Resize all other columns equally to adapt to new size of a column that is being resized. |
Table.AutoResize.AllColumns(readonly) GridLines :number
Enum for table grid line display modes.
- number
| Name | Type | Description |
|---|---|---|
None | number | No grid lines. |
Horizontal | number | Show only horizontal lines. |
Vertical | number | Show only vertical lines. |
Both | number | Show both horizontal and vertical lines. |
<h2>Setting to show only horizontal grid lines:</h2>
table.gridLines(Table.GridLines.Horizontal);(readonly) SortOrder :number
Enum for sort order.
- number
| Name | Type | Description |
|---|---|---|
None | number | No sorting order applied. |
Ascending | number | Values sorted from smallest to largest. |
Descending | number | Values sorted from largest to smallest. |
<h2>Sorting rows by column 2 in ascending order:</h2>
table.sortOrder(2, false, Table.SortOrder.Ascending);(readonly) Sorting :number
Enum for column sorting modes. Used in column definitions, e.g., { sorting: Table.Sorting.Natural }.
- number
| Name | Type | Description |
|---|---|---|
None | number | No sorting applied. |
Natural | number | (Default) Natural order sorting (alphanumeric). |
CaseInsensitive | number | Case-insensitive string sorting. |
Integer | number | Sort values as integers. |
Float | number | Sort values as floating-point numbers. |
table. Table.Sorting.Natural(readonly) columnCount :number
Returns the amount of columns currently in the Table.
- number
(readonly) rowCount :number
Returns a number of rows in the Table.
- number
(readonly) selectedRows :Array.<(string|number|boolean)>
Returns an array of currently selected rows.
- Array.<(string|number|boolean)>
Methods
addColumn(column, indexopt) → {Table}
Adds a column to a Table as a last column or at specified index. An empty data will be added at that column index for each row. For detail about column object format and all possible column properties refer to examples in the Table class description above. See usage example below.
| Name | Type | Attributes | Description |
|---|---|---|---|
column | object | A column Object with column properties, such as text, background color, etc. | |
index | number | <optional> | Insert at this position. Index is the original position of columns that were before columns are reordered. |
Returns this Table for method chaining.
- Type:
- Table
// How to add a column at an index 3
table.addColumn({text: "Customer Name", header_align:"center"}, 3);addRow(row, indexopt) → {Table}
Adds a new row at the end of table or at a specified index.
| Name | Type | Attributes | Description |
|---|---|---|---|
row | Array.<(string|number|boolean)> | An array of cell values of the row according to each column. Missing cells will be filled with empty data. | |
index | number | <optional> | Index at which to insert the row (original indexing, sorting is ignored). |
Returns an instance of this Table for method chaining.
- Type:
- Table
table.addRow(["John Dow", 45, true, "Charlotte, NC", "[View|Remove]"]);autoResizeColumns(valueopt) → {Table.AutoResize|Table}
Gets or sets columns' behavior when a single column is resized (usually manually by the user). Check description of each value of Table#AutoResize on this page. See usage example below.
| Name | Type | Attributes | Description |
|---|---|---|---|
value | Table. | <optional> | One of: Table.AutoResize.None (default), Table.AutoResize.NextColumn, Table.AutoResize.SubsequentColumns, Table.AutoResize.LastColumn, Table.AutoResize.AllColumns |
Returns current auto-resize mode if no argument is passed, otherwise the Table instance for chaining.
- Type:
- Table.
AutoResize |Table
// disables resizing of other columns when one column is resized
table.autoResizeColumns(Table.AutoResize.None);
// last column will be resize to accommodate room for a column being resized
table.autoResizeColumns(Table.AutoResize.LastColumn);canReorderColumns(enableopt) → {boolean|Table}
Sets or gets ability to change order of columns by dragging-dropping them by a user.
| Name | Type | Attributes | Description |
|---|---|---|---|
enable | boolean | <optional> | To enable reordering pass |
If setting a value this method returns this Table instance, when getting current value a boolean is returned.
- Type:
- boolean |
Table
cellAt(x, y) → {Array.<number>|null}
Gets a cell [row,column] located at specified X and Y coordinates relative to the Table's top-left corner, or null if no cell exist at specified coordinates.
| Name | Type | Description |
|---|---|---|
x | number | X |
y | number | Y |
Returns the cell position as a x and y position, or null if the coordinates are outside any cell.
- Type:
- Array.<number> |
null
cellEditing(row, column, new_orderopt, editingopt) → {boolean|Table}
Sets or gets whether a cell at specified row and columns is in editing mode.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
row | number | Row of the cell in question | ||
column | number | Column of the cell in question | ||
new_order | boolean | <optional> | false | Specified if row and column should be interpreted as new index (after row sorting and column reordering) or not. |
editing | boolean | <optional> | Set to |
When editing argument is passed, an instance of this Table is returned, otherwise current value is returned as boolean.
- Type:
- boolean |
Table
clicksToEdit(clicksopt) → {number|Table}
Sets or gets how many quick mouse clicks on editable cells are required to change the cell to editing mode.
| Name | Type | Attributes | Description |
|---|---|---|---|
clicks | number | <optional> | Amount of clicks: 1, 2, or 3. Default is 2 (double-click). |
Returns the current value if no parameters are provided; otherwise, and instance of this Table is returned.
- Type:
- number |
Table
column(i, new_orderopt, columnopt) → {Table|object}
Retrieve a column at specified index or updates an existing column at specified index.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
i | number | Index of the column to retrieve or update. | ||
new_order | boolean | <optional> | false | Should the index be interpreted as a new sorted order index or original order. Default is |
column | object | <optional> | An object of column properties to update in a column at specified index. To retrieve the column omit this argument. |
When retrieving the column a column object is returned, otherwise this Table instance is returned.
- Type:
- Table |
object
columnVisible(i, new_orderopt, visibleopt) → {boolean|Table}
Sets or get visibility of a column.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
i | number | Index of the column | ||
new_order | boolean | <optional> | false | Should the index be interpreted as a new sorted order index or original order. Default is |
visible | boolean | <optional> |
|
If visible argument is passed, then this Table object is returned, otherwise current visibility value is returned.
- Type:
- boolean |
Table
columns(copt) → {Array.<Object>|Table}
Gets or sets the list of columns for the table. To simple remove all columns pass null or empty Array.
- When passing an array of column objects, it replaces the existing columns.
- Passing
nullremoves all columns. - Passing fewer columns than currently exist will also remove the extra columns from all rows.
- Passing a boolean will return the current columns (instead of setting them):
true— returns columns in their current display order.false— returns columns in their original order (default).
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
c | Array.<Object> | | <optional> | false |
|
- Type:
- Array.<Object> |
Table
filter(filteropt) → {Table|string}
Sets row filter expression which can be a combination of conditions similar to if() condition in JavaScript.
Setting the filter hides rows that don't match specified filter criteria. When filter is set to "", filter gets cleared and all rows become visible again.
- Filter format is in the form of IF condition:
"column(index) operator comparison_value". - Note that a column must be specified on the left side of the condition and comparison value on the right side.
- Conditions can be combined using AND "&&", OR "||", and parenthesis "( )".
- Condition in parenthesis can be negated by "!" before parenthesis.
- Valid operators are:
! ( ) < == != > && || regex. comparison_valuecan be anumber,stringvalue,stringregular expression, orboolean.
See examples below.
| Name | Type | Attributes | Description |
|---|---|---|---|
filter | string | <optional> | Filter to use to display only rows that meet the specified conditions. Default is "" (no filter). |
Returns this Table when setting filter, otherwise returns current filter.
- Type:
- Table |
string
// Using case insensitive regular expression
table.filter(`column(1) regex "(?i)^Jim.*"`);// Filtering by numeric value
table.filter("column(1) < 50");// Filtering by date
table.filter(`column(3) > "2023-04-01 00:00:00" && column(3) < "2024-05-30 00:00:00"`);// Filtering by a boolean for checkbox
table.filter("column(4) != false");gridColor(coloropt) → {string|Table}
Gets or sets the color of the table's grid lines. Note: This only has an effect if grid lines are enabled.
| Name | Type | Attributes | Description |
|---|---|---|---|
color | string | <optional> | A valid CSS color string (e.g., "#000000" for black). |
Returns the current value if no parameter is provided; otherwise, returns the Table instance for chaining.
- Type:
- string |
Table
// Set the grid line color
table.gridColor("#000000");
// Get the current grid line color
alert(table.gridColor());gridLines(valueopt) → {Table.GridLines|Table}
Gets or sets which grid lines are visible (horizontal, vertical, both, or none).
| Name | Type | Attributes | Description |
|---|---|---|---|
value | Table. | <optional> | One of: Table.GridLines.None, Table.GridLines.Horizontal, Table.GridLines.Vertical, Table.GridLines.Both (default). See Table#GridLines. |
Returns the current value if no parameter is provided; otherwise, returns the Table instance for chaining.
- Type:
- Table.
GridLines |Table
headerEnabled(enableopt) → {boolean|Table}
Enables or disables Table header. When it's disabled, it doesn't respond to user's interaction.
| Name | Type | Attributes | Description |
|---|---|---|---|
enable | boolean | <optional> |
|
When setting, and instance of this Table is returned, otherwise a current value is returned.
- Type:
- boolean |
Table
headerSize(sizeopt) → {number|Table}
Sets or gets a size (height) of Table header. Set it to 0 to make it not visible.
| Name | Type | Attributes | Description |
|---|---|---|---|
size | number | <optional> | Height of table to set. Omit this argument to get current height. |
When setting, an instance of this Table is returned, otherwise a current value is returned.
- Type:
- number |
Table
moveColumn(from_index, to_index)
Moves a column from one position to another. Uses new column order for column indexes (if columns were reordered).
| Name | Type | Description |
|---|---|---|
from_index | number | Index of the column to move |
to_index | number | New position index |
onColumnEvents(callbackopt, removeopt) → {Table|Array.<function()>}
Gets, registers or unregisters a column event handler function. This event handler is called when a column is inserted, removed, resized, or moved (reordered).
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
callback | function | <optional> | The event handler function. Receives an event object. | |
remove | boolean | <optional> | false | Set to |
An array of handler functions if no arguments are passed, otherwise this component for method chaining.
- Type:
- Table |
Array.<function()>
// Example event object:
const e = {
target: Table, // The Table component that triggered the event.
type: string, // "insert", "remove", "move", "resize".
index: number // Only when type is "insert", "remove", or "resize". Index of the column.
fromIndex: number, // Only when type is "move". Indicates the previous index of the column.
toIndex: number, // Only when type is "move". Indicates the new index of the column.
fromSize: number, // Only when type is "resize". Indicates the previous size of the column.
toSize: number, // Only when type is "resize". Indicates the new size of the column.
interactive: boolean // `true` when column was moved by the user interacting with the GUI. `false` when it was made programmatically.
};onRowEvents(callbackopt, removeopt) → {Table|Array.<function()>}
Gets, registers or unregisters a row event handler function. This event handler is called when rows are inserted, removed, or cell value was updated (also check out onChange() event handler for to simply detect a cell value change).
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
callback | function | <optional> | The event handler function. Receives an event object. | |
remove | boolean | <optional> | false | Set to |
An array of handler functions if no arguments are passed, otherwise this component for method chaining.
- Type:
- Table |
Array.<function()>
// Example event object:
const e = {
target: object, // The Table component that triggered the event.
type: string, // "insert", "remove", "update".
row: number, // Only when one row was effected. Index of the row.
column: number // Only when type is "update". Column index of effected cell. Value of -1 means that all columns were effected.
fromRow: number // Only when multiple rows were effected. Indicates beginning index within the range of effected rows.
toRow: number // Only when multiple rows were effected. Indicates the last index within the range of effected rows.
interactive: boolean // Only when type is "update". `true` when update was made by the user interacting with the GUI. `false` when update was made programmatically.
};onSort(callbackopt, removeopt) → {Table|Array.<function()>}
Gets, registers or unregisters an event handler function for column sorting event. This event handler is called when a column is sorted by user or programmatically.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
callback | function | <optional> | The event handler function. Receives an event object. | |
remove | boolean | <optional> | false | Set to |
An array of handler functions if no arguments are passed, otherwise this component for method chaining.
- Type:
- Table |
Array.<function()>
// Example event object:
const e = {
target: Table, // The Table component that triggered the event.
type: Table.SortOrder, // Table.SortOrder.None, Table.SortOrder.Ascending, or Table.SortOrder.Descending.
column: number // Only when type is not Table.SortOrder.None. Column index.
newOrderColumn: number // Only when type is not Table.SortOrder.None. New column index, taking into account that columns may be re-ordered.
interactive: boolean // `true` when sorting was made by the user interacting with the GUI. `false` when it was made programmatically.
};primaryColumn(columnopt) → {number}
Gets or sets the primary column of the table. The primary column is used to generate a list (e.g., files or URIs) when rows are dragged from the Table, and the table's data type includes FileList, URIList, or URL.
| Name | Type | Attributes | Description |
|---|---|---|---|
column | number | <optional> | The value to set for the primary column. If omitted, the current primary column value is returned. |
- The current value of the primary column if no argument is provided (default is 0), or the instance of
thisTable for method chaining.
- Type:
- number
removeColumn(i, new_orderopt) → {Table}
Removes a column at specified index. Also data at that column index for each row will also be removed.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
i | number | Index of the column to remove. | ||
new_order | boolean | <optional> | false | Should the index be interpreted as a new sorted order index or original order. Default is |
Returns this Table instance for method chaining.
- Type:
- Table
removeRow(i, new_orderopt) → {Table}
Removes one row at a specified index.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
i | number | Index of the row to remove. | ||
new_order | boolean | <optional> | false | Indicates if given index is adjusted the sort order. |
Returns an instance of this Table for method chaining.
- Type:
- Table
row(index, new_orderopt, rowopt) → {Array.<(string|number|boolean)>|Table}
Gets or updates an existing row at a specified index.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
index | number | Index of the row. | ||
new_order | boolean | <optional> | false | Specifies if "index" argument is based on new sorted order (true) or not (false). |
row | Array.<(string|number|boolean)> | <optional> | array - A new row that will replace an existing row at specified index. |
When retrieving a row an Array is returned. When updating updating a row an instance of this Table is returned.
- Type:
- Array.<(string|number|boolean)> |
Table
// To update values of an existing row at index 5
table.row(5, false, ["Jane Dow", 40, false, "Charlotte, NC", "[View|Remove]"]);rowBackground(color) → {string|Table}
Sets or gets a background color of rows.
| Name | Type | Description |
|---|---|---|
color | string | Hex style color string (e.g. #004453 or #00445377 with alpha), or |
Returns current value when no argument is passed, otherwise returns this Table instance for method chaining.
- Type:
- string |
Table
rowSize(heightopt, indexopt) → {number|Table}
Gets/Sets/Resets the height of all table rows or one existing row at specified index.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
height | number | | <optional> | Set | |
index | number | <optional> | -1 | Index of a specific row to apply given height to. Index is the original row position, it doesn't change due to sorting. -1 means that height will be applied to all rows. |
- If no argument is passed or
heightis set toundefinedthen current value is returned, otherwisethisTable instance is returned for method chaining.
- Type:
- number |
Table
// To get height of all rows
let h = table.rowSize();
// To get a height of a specific row at index 5
let h = table.rowSize(undefined, 5);// To set height to all rows
table.rowSize(40);
// To set height to row at index 5
table.rowSize(40, 5);// To reset height of all rows to default height
table.rowSize(null);
// To reset height of row at index 5 to default height
table.rowSize(null, 5);rowStyle(index, new_orderopt, styleopt) → {Object|Table}
Sets or gets a row style at a specified row index. When the row is removed, the row style is also removed.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
index | number | The row index. | ||
new_order | boolean | <optional> | false | Should the index be interpreted as a new sorted order index or original order. Default is |
style | Object | | <optional> | An object containing style properties to set, |
- When setting the style, an instance of
thisTable is returned, otherwise a current style of specified row is returned.
- Type:
- Object |
Table
// how to set style for a row index 5
table.rowStyle(5, false, {background:"#FF0000", color:"#FFAAAA", size: 40}});
// how to reset one style a row at index 5
table.rowStyle(5, false, {color:"#FFAAAA"}});
// how to remove all styles from a row at index 5
table.rowStyle(5, false, null});// How to get style of a row at index 5
let style = table.rowStyle(5);
console.log(style);rows(rows_or_new_orderopt, filteropt) → {Array|Table}
Sets or gets all rows (array of arrays representing rows and cells) of the table. When setting rows, it replaces existing rows. To simply remove all rows pass null or empty Array as first argument. When getting rows you can pass "true" to get them in the new sorted order instead of original order. To filter out some rows pass filter argument. See Table#filter function's documentation for details about filter expression.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
rows_or_new_order | Array | | <optional> | false | Array of rows to set for the table, or boolean |
filter | string | <optional> | Filter expression to retrieving only rows that meet the specified criteria. Default is |
When settings rows to the table an instance of this this Table is returned. When retrieving rows a two-dimensional Array of rows is returned.
- Type:
- Array |
Table
selectAll(selectedopt) → {Table}
Selects/Deselects all rows in the Table
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
selected | boolean | <optional> | true |
|
Returns an instance of this Table for method chaining.
- Type:
- Table
selectedCell(rowopt, columnopt) → {Array.<number>|Table}
Sets or gets a row and a column of selected cell.
| Name | Type | Attributes | Description |
|---|---|---|---|
row | number | <optional> | Row of a cell. (Original order is used, sorting is disregarded.) |
column | number | <optional> | Column of a cell (required if row is specified). (Original order is used, column reordering is disregarded.) |
When both row and cell are passed, an instance of this Table is returned, otherwise a currently selected row and column is returned as an array of integers [row, column], or NULL if there is no selection.
- Type:
- Array.<number> |
Table
selectedIndex(index) → {number|Table}
Sets or returns an index of a single selected row. If multiple rows are selected, it returns an index of the first one. Original row order is used (sorting is disregarded).
| Name | Type | Description |
|---|---|---|
index | number | Index of the row to select. If index is not valid, it will have no effect. |
When setting index, an instance of this Table is returned, otherwise a currently selected first row's index is returned, or -1 if no row is selected.
- Type:
- number |
Table
selectedValue(valueopt) → {string|number|boolean|Table}
Sets or gets a value in currently selected cell (row and column).
| Name | Type | Attributes | Description |
|---|---|---|---|
value | string | | <optional> | Value to set to the cell. Omit to get the value instead of setting. |
When setting a value an instance of this Table is returned, otherwise a current value is returned.
- Type:
- string |
number | boolean | Table
selection(selectionopt, new_orderopt, add_removeopt) → {Table|Array.<number>}
Sets/Removes selection of single row, list, or a range of rows, or gets an array of currently selected rows. Without arguments this returns an array of currently selected row indexes.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
selection | number | | <optional> | One index, an array of indexes, or a index range object {from:number, to:number}. Pass | |
new_order | boolean | <optional> | false | Use new order after the rows were sorted (true) instead of using original order of rows by default (false). Default is false. |
add_remove | boolean | <optional> | Instead of setting a new selection use |
When setting selection, an instance of this Table is returned. When getting selection, an array if indexes is returned.
- Type:
- Table |
Array.<number>
// Example of clearing current selection
table.selection(null);// Examples of setting selection using a single index:
table.selection(5) - Selects a single row.
table.selection(5, true) - Selects a single row based on new sort order.
table.selection(5, false, true) - Selects an additional single row (if it wasn't selected yet) based on original order.// Examples of selecting a range of rows using an index range object:
table.selection({from:5, to:9}) - Selects only a range of rows from index 5 to 9 (Only possible when selection mode is set to SelectionMode.Range or SelectionMode.Multiple).
table.selection({from:5, to:9}, true) - Selects only a range of rows from index 5 to 9 based on new sort order (Only possible when selection mode is set to SelectionMode.Range or SelectionMode.Multiple).
table.selection({from:5, to:9}, true, true) - Selects a range of rows from index 5 to 9 based on new sort order in addition to previously selected rows (Only possible when selection mode is set to SelectionMode.Range or SelectionMode.Multiple).// Examples of selecting/deselecting multiple rows using an array of indexes:
table.selection([6, 7, 4, 1]) - Selects only indexes specified in the array (Multiple intervals (ranges) are only possible when selection mode is set to SelectionMode.Multiple).
table.selection([6, 7, 4, 1], true) - Selects only indexes specified in the array based on new sort order (Multiple intervals (ranges) are only possible when selection mode is set to SelectionMode.Multiple).
table.selection([6, 7], true, false) - Deselects rows at indexes specified in the array based on new sort order from previously selected rows.selectionMode(modeopt)
Sets or gets selection mode, how user is able to select rows; only one at a time, any multiple rows, or only a range of rows. Default is "Table.Single".
| Name | Type | Attributes | Description |
|---|---|---|---|
mode | SelectionMode | <optional> | One of: SelectionMode.Single (default), SelectionMode.Range, SelectionMode.Multiple. See SelectionMode. |
(SelectionMode|Table} When setting mode, an instance of this Table is returned, otherwise current mode is returned.
sortOrder(columnopt, new_column_orderopt, orderopt) → {Table|object|null}
Gets or sets current sort state of the table rows by specifying column and order. Does not sort by columns that are set to be not sortable.
- When called without arguments, returns the current sort configuration.
- When called with arguments, updates the sort state for the specified column.
- Columns marked as non-sortable will be ignored.
See usage examples below.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
column | number | | <optional> | Column index to sort by, or | |
new_column_order | boolean | <optional> | false | Whether the given column index should be interpreted as a new column order (useful if columns were reordered). |
order | Table. | <optional> | Table.SortOrder.None | One of: Table.SortOrder.None (default), Table.SortOrder.Ascending, Table.SortOrder.Descending. |
Returns this Table object for method chaining when settings a sort, otherwise returns current sort order as {column:number, order:Table.SortOrder} or null when table rows are not sorted.
- Type:
- Table |
object | null
<h2>Setting a sort column and order:</h2>
// Sorts rows by column 2 in descending order
table.sortOrder(2, false, Table.SortOrder.Descending);
// Resets sorting by column 2 while still sorting by previously sorted columns (if any)
table.sortOrder(2, false, Table.SortOrder.None);
// Resets row sorting for all columns. Rows become unsorted.
table.sortOrder(null);<h2>Getting current sort state:</h2>
let sorting = table.sortOrder();
// returns `null` if there was no sorting applied to the table
// or object like {column: 2, order: Table.SortOrder.Descending} if column 2 is currently sorted.
// Returned `column` index is the original column index (remain same even after after columns were reordered).triStateSorting(enabledopt) → {boolean|Table}
Sets or gets whether sorting can be toggled to unsorted state.
| Name | Type | Attributes | Description |
|---|---|---|---|
enabled | boolean | <optional> |
|
When setting, and instance of this Table is returned, otherwise a current value is returned.
- Type:
- boolean |
Table
valueAt(row, column, new_orderopt, valueopt) → {string|number|boolean|Table}
Sets or gets a value at a specified row and column. Returns undefined if specified row or column doesn't exist.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
row | number | Index of the row in question | ||
column | number | Index of the column in question | ||
new_order | boolean | <optional> | false | To use the new sorted order of rows and columns or not |
value | string | | <optional> | The value to set the specified cell |
Returns the current cell value if new value is provided by value parameter; otherwise, returns the Table instance for chaining.
- Type:
- string |
number | boolean | Table