new (require("nmodule/webEditors/rc/wb/mgr/model/MgrModel"))(params)
API Status: Development
A layer that adds edit/add/remove functionality on top of aComponentTableModel
.
Due to the incubating status of the manager framework, it is not
recommended that you extend MgrModel
directly. Instead, extendDeviceMgrModel
or PointMgrModel
: these will provide more robust
functionality for most use cases.
Extends:
Parameters:
Name | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
Properties
|
- See:
-
- module:nmodule/driver/rc/wb/mgr/DeviceMgrModel
- module:nmodule/driver/rc/wb/mgr/PointMgrModel
Methods
-
<static> getColumns( [flags])
-
Get the columns contained in this
MgrModel
.Parameters:
Name Type Argument Description flags
Number <optional>
if given, only return columns that have these
flags.Returns:
- Type
- Array.<module:nmodule/webEditors/rc/wb/mgr/model/MgrColumn>
-
addInstances(instances [, names])
-
Add the instances to this model, to be called when an add dialog or
other add operation is committed. The default implementation is to add the
given instances to the underlyingComponentSource
container, which will
commit these changes up to the station.Like Workbench, parented instances will be unparented and re-added to the
container component. (Workbench does this via a Mark; here it will be
done using BajaScript remove/add calls.)Parameters:
Name Type Argument Description instances
Array.<baja.Component> the instances to add
names
Array.<String> <optional>
the desired slot names for the instances.
If omitted, default names derived from the instance Types will be used.Returns:
promise to be resolved when the instances are
added, or rejected if the add fails.- Type
- Promise
-
destroy()
-
Clean up the
MgrModel
when the parentManager
is being destroyed. This is
an opportunity to unhook any remaining event handlers on the model or its data source.Returns:
Promise.<*>
-
getColumn(name)
-
Get the column in this model matching the given name.
Parameters:
Name Type Description name
String - Inherited From:
Returns:
the matching
column, ornull
if not found -
getColumnIndex(column)
-
Get the index of the given column.
Parameters:
Name Type Description column
module:nmodule/webEditors/rc/wb/table/model/Column Returns:
the column's index, or -1 if not found
- Type
- number
-
getColumns( [flags])
-
Get the current set of columns, optionally filtered by flags.
Parameters:
Name Type Argument Description flags
Number <optional>
if given, only return columns that have these
flags.Returns:
- Type
- Array.<module:nmodule/webEditors/rc/wb/table/model/Column>
-
getComponentSource()
-
Get the
ComponentSource
backing this table model.Returns:
-
getEditableColumns()
-
Return all columns with the
EDITABLE
flag set.Returns:
- Type
- Array.<module:nmodule/webEditors/rc/wb/table/model/Column>
-
getNewTypes()
-
Get the
MgrTypeInfo
instances representing the types that are acceptable to add to
this model.Returns:
array of MgrTypeInfos to add
- Type
- Array.<module:nmodule/webEditors/rc/wb/mgr/MgrTypeInfo>
-
getRowIndex(row)
-
Get the index of the given row.
Parameters:
Name Type Description row
module:nmodule/webEditors/rc/wb/table/model/Row Returns:
the row's index, or -1 if not found
- Type
- number
-
getRows()
-
Get the current set of rows.
- Inherited From:
Returns:
- Type
- Array.<module:nmodule/webEditors/rc/wb/table/model/Row>
-
getValueAt(x, y)
-
Ask the column at the given index for the value from the row at the
given index.Parameters:
Name Type Description x
Number column index
y
Number row index
Returns:
promise to be resolved with the value
- Type
- Promise
-
insertColumns(toInsert [, index])
-
Add new columns to the model. Will trigger a
columnsAdded
tinyevent
.Parameters:
Name Type Argument Description toInsert
Array.<module:nmodule/webEditors/rc/wb/table/model/Column> index
Number <optional>
index to insert the columns; will append to the
end if omittedReturns:
promise to be resolved if the insert is
successful- Type
- Promise
-
insertRows(toInsert [, index])
-
Add new rows to the model. If non-
Row
instances are given, they will be
converted toRow
s usingmakeRow()
.Will trigger a
rowsAdded
tinyevent
.Parameters:
Name Type Argument Description toInsert
Array.<(module:nmodule/webEditors/rc/wb/table/model/Row|*)> index
Number <optional>
index to insert the rows; will append to the
end if omittedReturns:
promise to be resolved if the insert is
successful- Type
- Promise
-
makeRow(subject)
-
Instantiate a new row for the given subject.
insertRows
will delegate
to this if values are passed in rather thanRow
instances. Override
as necessary.Parameters:
Name Type Description subject
* - Inherited From:
Returns:
-
newInstance(typeInfo)
-
Override point to customize how new instances of the selected
MgrTypeInfo
are instantiated. The default implementation is to simply delegate to the type
info's #newInstance() function.Parameters:
Name Type Description typeInfo
module:nmodule/webEditors/rc/wb/mgr/MgrTypeInfo Returns:
- Type
- baja.Value | Promise
-
removeColumns(toRemove [, end])
-
Remove columns from the model. Will trigger a
columnsRemoved
tinyevent
.Parameters:
Name Type Argument Description toRemove
Array.<module:nmodule/webEditors/rc/wb/table/model/Column> | Number the columns to remove; or, start index
end
Number <optional>
end index
Returns:
promise to be resolved if the remove is
successful- Type
- Promise
-
removeRows(toRemove [, end])
-
Remove rows from the model. Will trigger a
rowsRemoved
tinyevent
, with
parameters:rowsRemoved
: the rows that were removedindices
: the original indices of the rows that were removed
Note that
rowsRemoved
andindices
will always be sorted by their
original index in the model's rows, regardless of the order of rows passed
to theremoveRows
function.Parameters:
Name Type Argument Description toRemove
Array.<module:nmodule/webEditors/rc/wb/table/model/Row> | Number the rows to remove; or, start index
end
<optional>
end index
Returns:
promise to be resolved if the remove is
successful- Type
- Promise
-
sort(sortFunction)
-
Sort the table's rows according to the given sort function. Emits a
rowsReordered
event.Remember that
Array#sort
is synchronous, so if the sort needs to use
any data that is asynchronously retrieved, the async work must be performed
before the sort so that the sort function can work synchronously.Parameters:
Name Type Description sortFunction
function standard array sort function to receive
twoRow
instances- Inherited From:
Throws:
-
if a non-Function is given
- Type
- Error