Expand all

mw.widgets.TableWidgetModel

TableWidget model.

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.

clearWithProperties() #

Clears the table data, as well as all row and column properties.

Source:

Fires:

Clears the table data, as well as all row and column properties.

getAllColumnProperties() → {Array} #

Get properties of all columns.

Source:

Returns:

An array of objects containing key, index and label properties for each column

Type
Array
Get properties of all columns.

getAllRowProperties() → {Array} #

Get properties of all rows.

Source:

Returns:

An array of objects containing key, index and label properties for each row

Type
Array
Get properties of all rows.

getColumnProperties(handle) → {Object|null} #

Get properties of a given column.

Parameters:

Name Type Description
handle string | number

The key (or numeric index) of the column

Source:

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
Get properties of a given column.

getRowProperties(handle) → {Object|null} #

Get properties of a given row.

Parameters:

Name Type Description
handle string | number

The key (or numeric index) of the row

Source:

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
Get properties of a given row.

getTableProperties() → {Object} #

Get all table properties.

Source:

Returns:

Type
Object
Get all table properties.

getValidationPattern() → {RegExp|function|string} #

Get the validation pattern to test cells against.

Source:

Returns:

Type
RegExp | function | string
Get the validation pattern to test cells against.

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.

Source:

Fires:

Inserts a column into the table.

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.

Source:

Fires:

Inserts a row into the table.

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

Source:

Fires:

Removes a column from the table.

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

Source:

Fires:

Removes a row from the table.

setData(data) #

Set the table data.

Parameters:

Name Type Description
data Array

The new table data

Source:
Set the table data.

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

Source:

Fires:

Set the value of a particular cell.

setupTable() #

Triggers the initialization process and builds the initial table.

Source:

Fires:

Triggers the initialization process and builds the initial table.

Type Definitions

Config #

Configuration options.

Type:

Properties:

Name Type Attributes Default Description
rows Array optional

An array of objects containing key and label properties for every row

cols Array optional

An array of objects containing key and label properties for every column

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.

Source:
Configuration options.

Events

clear(clear) #

Fired when the table data is wiped.

Parameters:

Name Type Description
clear boolean

Clear row/column properties

Source:
Fired when the table data is wiped.

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

Source:
Fired when a new row is inserted into the table.

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

Source:
Fired when a new row is inserted into the table.

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

Source:
Fired when a column is removed from the table.

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

Source:
Fired when a row is removed from the table.

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

Source:
Fired when a value inside the table has changed.