Expand all

mw.widgets.RowWidgetModel

RowWidget model.

Constructor

new mw.widgets.RowWidgetModel([config]) #

Create an instance of mw.widgets.RowWidgetModel.

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Properties:
Name Type Attributes Default Description
data Array optional

An array containing all values of the row

keys Array optional

An array of keys for easy cell selection

validate RegExp | function | string optional

Validation pattern to apply on every cell

label string optional
''

Row label. Defaults to empty string.

showLabel boolean optional
true

Show row label. Defaults to true.

deletable boolean optional
true

Allow row to be deleted. Defaults to true.

Mixes in:
Source:

Methods

clear() #

Clears the row data.

clearWithProperties() #

Clears the row data, as well as all cell properties.

Source:

Fires:

Clears the row data, as well as all cell properties.

getAllCellProperties() → {Array} #

Get properties of all cells.

Source:

Returns:

An array of objects containing key and index properties for each cell

Type
Array
Get properties of all cells.

getCellProperties(handle) → {Object|null} #

Get properties of a given cell.

Parameters:

Name Type Description
handle string | number

The key (or numeric index) of the cell

Source:

Returns:

An object containing the key and index properties of the cell. Returns null if the cell can't be found.

Type
Object | null
Get properties of a given cell.

getRowProperties() → {Object} #

Get all row properties.

Source:

Returns:

Type
Object
Get all row 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.

insertCell([data], [index], [key]) #

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 number | string optional

The data to insert to the cell.

index number optional

The index in which to insert the new cell. If unset or set to null, the cell will be added at the end of the row.

key string optional

A key to quickly select this cell. If unset or set to null, no key will be set.

Source:

Fires:

Inserts a row into the table.

removeCell(handle) #

Removes a cell from the table. If the cell removed isn't at the end of the table, all the following cells will be shifted back one cell.

Parameters:

Name Type Description
handle number | string

The key or numerical index of the cell to remove

Source:

Fires:

Removes a cell from the table.

setData(data) #

Set the row data.

Parameters:

Name Type Description
data Array

The new row data

Source:
Set the row data.

setIndex(index) #

Set the row index.

Parameters:

Name Type Description
index number

The new row index

Source:

Fires:

Set the row index.

setLabel(label) #

Set the row label.

Parameters:

Name Type Description
label number

The new row label

Source:

Fires:

Set the row label.

setValue(handle, value) #

Set the value of a particular cell.

Parameters:

Name Type Description
handle number | string

The index or key of the cell

value any

The new value

Source:

Fires:

Set the value of a particular cell.

setupRow() #

Triggers the initialization process and builds the initial row.

Source:

Fires:

Triggers the initialization process and builds the initial row.

Events

clear(clear) #

Fired when the row is cleared.

Parameters:

Name Type Description
clear boolean

Clear cell properties

Source:
Fired when the row is cleared.

insertCell(data, index) #

Fired when a new cell is inserted into the row.

Parameters:

Name Type Description
data Array

The initial data

index number

The index in which to insert the new cell

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

labelUpdate() #

Fired when the row label might need to be updated.

Source:
Fired when the row label might need to be updated.

removeCell(index) #

Fired when a cell is removed from the row.

Parameters:

Name Type Description
index number

The removed cell index

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

valueChange(index, value) #

Fired when a value inside the row has changed.

Parameters:

Name Type Description
index number

The column index of the updated cell

value number

The new value

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