new mw.widgets.TableWidgetModel(configopt)
#
TableWidget model.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
config |
mw.widgets.TableWidgetModel~Config |
<optional> |
Configuration options |
- Mixes In:
- Source:
Methods
clear()
#
Clears the table data.
Fires:
clearWithProperties()
#
Clears the table data, as well as all row and column properties.
Fires:
getAllColumnProperties() → {Array}
#
Get properties of all columns.
Returns:
An array of objects containing key
, index
and
label
properties for each column
- Type
- Array
getAllRowProperties() → {Array}
#
Get properties of all rows.
Returns:
An array of objects containing key
, index
and label
properties for each row
- Type
- Array
getColumnProperties(handle) → {Object|null
}
#
null
}
#
Get properties of a given column.
Parameters:
Name | Type | Description |
---|---|---|
handle |
string | number | The key (or numeric index) of the column |
Returns:
An object containing the key
, index
and
label
properties of the column.
Returns null
if the column can't be found.
- Type
-
Object
|
null
getRowProperties(handle) → {Object|null
}
#
null
}
#
Get properties of a given row.
Parameters:
Name | Type | Description |
---|---|---|
handle |
string | number | The key (or numeric index) of the row |
Returns:
An object containing the key
, index
and label
properties of the row.
Returns null
if the row can't be found.
- Type
-
Object
|
null
getTableProperties() → {Object}
#
Get all table properties.
Returns:
- Type
- Object
getValidationPattern() → {RegExp|function|string}
#
Get the validation pattern to test cells against.
Returns:
- Type
- RegExp | function | string
insertColumn(dataopt, indexopt, keyopt, labelopt)
#
Inserts a column into the table. If the column isn't added at the end of the table, all the following data will be shifted back one column.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
Array |
<optional> |
The data to insert to the column. |
index |
number |
<optional> |
The index in which to insert the new column. If unset or set to null, the column will be added at the end of the table. |
key |
string |
<optional> |
A key to quickly select this column. If unset or set to null, no key will be set. |
label |
string |
<optional> |
A label to display next to the column. If unset or set to null, the key will be used if there is one. |
Fires:
insertRow(dataopt, indexopt, keyopt, labelopt)
#
Inserts a row into the table. If the row isn't added at the end of the table, all the following data will be shifted back one row.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
Array |
<optional> |
The data to insert to the row. |
index |
number |
<optional> |
The index in which to insert the new row. If unset or set to null, the row will be added at the end of the table. |
key |
string |
<optional> |
A key to quickly select this row. If unset or set to null, no key will be set. |
label |
string |
<optional> |
A label to display next to the row. If unset or set to null, the key will be used if there is one. |
Fires:
removeColumn(handle)
#
Removes a column from the table. If the column removed isn't at the end of the table, all the following columns will be shifted back one column.
Parameters:
Name | Type | Description |
---|---|---|
handle |
number | string | The key or numerical index of the column to remove |
Fires:
removeRow(handle)
#
Removes a row from the table. If the row removed isn't at the end of the table, all the following rows will be shifted back one row.
Parameters:
Name | Type | Description |
---|---|---|
handle |
number | string | The key or numerical index of the row to remove |
Fires:
setValue(row, col, value)
#
Set the value of a particular cell.
Parameters:
Name | Type | Description |
---|---|---|
row |
number | string | The index or key of the row |
col |
number | string | The index or key of the column |
value |
any | The new value |
Fires:
setupTable()
#
Triggers the initialization process and builds the initial table.
Fires:
Type Definitions
Config
#
Configuration options
Type:
- Object
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rows |
Array |
<optional> |
An array of objects containing |
|
cols |
Array |
<optional> |
An array of objects containing |
|
data |
Array |
<optional> |
An array containing all values of the table |
|
validate |
RegExp | function | string |
<optional> |
Validation pattern to apply on every cell |
|
showHeaders |
boolean |
<optional> |
true | Show table header row. Defaults to true. |
showRowLabels |
boolean |
<optional> |
true | Show row labels. Defaults to true. |
allowRowInsertion |
boolean |
<optional> |
true | Allow row insertion. Defaults to true. |
allowRowDeletion |
boolean |
<optional> |
true | Allow row deletion. Defaults to true. |
Configuration options
.Events
clear(clear)
#
Fired when the table data is wiped.
Parameters:
Name | Type | Description |
---|---|---|
clear |
boolean | Clear row/column properties |
insertColumn(data, index, key, label)
#
Fired when a new row is inserted into the table.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array | The initial data |
index |
number | The index in which to insert the new column |
key |
string | The column key |
label |
string | The column label |
insertRow(data, index, key, label)
#
Fired when a new row is inserted into the table.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array | The initial data |
index |
number | The index in which to insert the new row |
key |
string | The row key |
label |
string | The row label |
removeColumn(index, key)
#
Fired when a column is removed from the table.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | The removed column index |
key |
string | The removed column key |
removeRow(index, key)
#
Fired when a row is removed from the table.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | The removed row index |
key |
string | The removed row key |
valueChange(row, column, value)
#
Fired when a value inside the table has changed.
Parameters:
Name | Type | Description |
---|---|---|
row |
number | The row index of the updated cell |
column |
number | The column index of the updated cell |
value |
any | The new value |