selection([selection], [new_order], [add_remove])
Class: Table.
Description:
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.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
|
|
number | Array.<number> | Object | null |
One index, an array of indexes, or a index range object {from:number, to:number}. Pass |
|
|
|
boolean |
false |
Use new order after the rows were sorted (true) instead of using original order of rows by default (false). Default is false. |
|
|
boolean |
Instead of setting a new selection use |
Returns:
When setting selection, an instance of this Table is returned. When getting selection, an array if indexes is returned.
Type: Table | Array.<number>
Examples:
// 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.
