Constructor
new mw.widgets.TableWidgetModel([config])
#
Create an instance of mw.widgets.TableWidgetModel
.
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:
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:
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
getValidationPattern() → {RegExp|function|string}
#
Get the validation pattern to test cells against.
Returns:
insertColumn([data], [index], [key], [label])
#
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([data], [index], [key], [label])
#
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:
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:
Fires:
setValue(row, col, value)
#
setupTable()
#
Triggers the initialization process and builds the initial table.
Fires:
Type Definitions
Config
#
Configuration options.
Type:
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. |
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)
#
insertRow(data, index, key, label)
#
removeColumn(index, key)
#
Fired when a column is removed from the table.
Parameters:
removeRow(index, key)
#
Fired when a row is removed from the table.