new (require("nmodule/webEditors/rc/wb/mgr/model/MgrModel"))(params)
- Description:
API Status: Development
A layer that adds edit/add/remove functionality on top of a
ComponentTableModel.Due to the incubating status of the manager framework, it is not
recommended that you extendMgrModeldirectly. Instead, extend
DeviceMgrModelorPointMgrModel: these will provide more robust
functionality for most use cases.
- Source:
- See:
-
- module:nmodule/driver/rc/wb/mgr/DeviceMgrModel
- module:nmodule/driver/rc/wb/mgr/PointMgrModel
Extends:
Parameters:
| Name | Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
Properties
|
Extends
Methods
addInstances(instances, namesopt) → {Promise.<Array.<baja.Component>>}
- Description:
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 underlyingComponentSourcecontainer, 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.)
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
instances |
Array.<baja.Component> | the instances to add |
|
names |
Array.<String> |
<optional> |
the desired slot names for the instances. |
Returns:
as of Niagara 4.13, this will
resolve with an array of the components that were successfully added. Or:
rejected if the add fails.
- Type
- Promise.<Array.<baja.Component>>
clearRows() → {Promise}
- Description:
Remove all rows from the model.
Will trigger a
rowsRemovedtinyevent, with
parameters:rowsRemoved: the rows that were removedindices: the original indices of the rows that were removed
- Source:
- Inherited From:
Returns:
- Type
- Promise
destroy()
- Description:
Clean up the
MgrModelwhen the parentManageris being destroyed. This is
an opportunity to unhook any remaining event handlers on the model or its data source.
- Source:
Returns:
Promise.<*>
getColumn(name) → {module:nmodule/webEditors/rc/wb/table/model/Column}
- Description:
Get the column in this model matching the given name.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String |
Returns:
the matching
column, or null if not found
getColumnIndex(column) → {number}
- Description:
Get the index of the given column.
- Source:
- Inherited From:
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(flagsopt) → {Array.<module:nmodule/webEditors/rc/wb/table/model/Column>}
- Description:
Get the current set of columns, optionally filtered by flags.
- Source:
- Inherited From:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
flags |
Number |
<optional> |
if given, only return columns that have these |
Returns:
- Type
- Array.<module:nmodule/webEditors/rc/wb/table/model/Column>
getComponentSource() → {module:nmodule/webEditors/rc/wb/table/model/ComponentSource}
- Description:
Get the
ComponentSourcebacking this table model.
- Source:
- Inherited From:
Returns:
getEditableColumns() → {Array.<module:nmodule/webEditors/rc/wb/table/model/Column>}
- Description:
Return all columns with the
EDITABLEflag set.
- Source:
- Inherited From:
Returns:
- Type
- Array.<module:nmodule/webEditors/rc/wb/table/model/Column>
getNewTypes() → {Array.<module:nmodule/webEditors/rc/wb/mgr/MgrTypeInfo>}
- Description:
Get the
MgrTypeInfoinstances representing the types that are acceptable to add to
this model.
- Source:
Returns:
array of MgrTypeInfos to add
- Type
- Array.<module:nmodule/webEditors/rc/wb/mgr/MgrTypeInfo>
getRow(i) → {module:nmodule/webEditors/rc/wb/table/model/Row|undefined}
- Description:
Get the row at the given index.
- Source:
- Since:
- Niagara 4.12
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
i |
number |
Returns:
the row at this index, or
undefined if not present
- Type
- module:nmodule/webEditors/rc/wb/table/model/Row | undefined
getRowCount() → {Number}
- Description:
Get the number of rows in the TableModel.
- Source:
- Since:
- Niagara 4.12
- Inherited From:
Returns:
- Type
- Number
getRowIndex(row) → {number}
- Description:
Get the index of the given row. If a filter is applied, returns the index of the row among the
currently filtered rows.
- Source:
- Inherited From:
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() → {Array.<module:nmodule/webEditors/rc/wb/table/model/Row>}
- Description:
Get the current set of rows.
- Source:
- Inherited From:
Returns:
- Type
- Array.<module:nmodule/webEditors/rc/wb/table/model/Row>
getValueAt(x, y) → {Promise}
- Description:
Ask the column at the given index for the value from the row at the
given index.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
x |
Number | column index |
y |
Number | row index |
Returns:
promise to be resolved with the value
- Type
- Promise
insertColumns(toInsert, indexopt) → {Promise}
- Description:
Add new columns to the model. Will trigger a
columnsAddedtinyevent.
- Source:
- Inherited From:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
toInsert |
Array.<module:nmodule/webEditors/rc/wb/table/model/Column> | ||
index |
Number |
<optional> |
index to insert the columns; will append to the |
Returns:
promise to be resolved if the insert is
successful
- Type
- Promise
insertRows(toInsert, indexopt) → {Promise}
- Description:
Add new rows to the model. If non-
Rowinstances are given, they will be
converted toRows usingmakeRow().If a row filter has been set to a non-null function the index passed to this
function will be relative to the resulting filtered array returned from getRows().Will trigger a
rowsAddedtinyevent.
- Source:
- Inherited From:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
toInsert |
Array.<(module:nmodule/webEditors/rc/wb/table/model/Row|*)> | ||
index |
Number |
<optional> |
index to insert the rows; will append to the |
Returns:
promise to be resolved if the insert is
successful
- Type
- Promise
makeRow(comp) → {module:nmodule/webEditors/rc/wb/table/model/Row}
- Description:
Ensures that the row's icon is set to the component's icon.
- Source:
- Since:
- Niagara 4.14
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
comp |
baja.Component | module:nmodule/webEditors/rc/wb/table/model/Row |
Returns:
newInstance(typeInfo) → {baja.Value|Promise}
- Description:
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.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
typeInfo |
module:nmodule/webEditors/rc/wb/mgr/MgrTypeInfo |
Returns:
- Type
- baja.Value | Promise
newInstances(params) → {Promise.<Array.<baja.Value>>}
- Description:
Override point to customize how
countnumber of new instances of a selected
MgrTypeInfoare instantiated. The default implementation is to simply delegate to
the model's #newInstance() method.
- Source:
- Since:
- Niagara 4.14
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object | the parameters to be used to create new instances Properties
|
Returns:
- Type
- Promise.<Array.<baja.Value>>
postEdit(instances) → {Promise.<(Array.<baja.Component>|undefined)>}
- Description:
Override point, that allows the post-processing of the edited row(s) after they have been
posted to the server.
- Source:
- Since:
- Niagara 4.14
Parameters:
| Name | Type | Description |
|---|---|---|
instances |
Array.<baja.Component> | the instances that were edited |
Returns:
- Type
- Promise.<(Array.<baja.Component>|undefined)>
postMatch(instances) → {Promise.<(Array.<baja.Component>|undefined)>}
- Description:
Override point, that allows the post-processing of the matched row(s) after they have been
posted to the server.
- Source:
- Since:
- Niagara 4.14
Parameters:
| Name | Type | Description |
|---|---|---|
instances |
Array.<baja.Component> | the instances that were matched |
Returns:
- Type
- Promise.<(Array.<baja.Component>|undefined)>
removeColumns(toRemove, endopt) → {Promise}
- Description:
Remove columns from the model. Will trigger a
columnsRemovedtinyevent.
- Source:
- Inherited From:
Parameters:
| Name | Type | Attributes | 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, endopt) → {Promise}
- Description:
Remove rows from the model. Will trigger a
rowsRemovedtinyevent, with
parameters:rowsRemoved: the rows that were removedindices: the original indices of the rows that were removed
If a row filter has been set to a non-null function any indices passed to this
function will be relative to the resulting filtered array returned from getRows().Note that
rowsRemovedandindiceswill always be sorted by their
original index in the model's rows, regardless of the order of rows passed
to theremoveRowsfunction.
- Source:
- Inherited From:
Parameters:
| Name | Type | Attributes | 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
setRowFilter(rowFilterFunction) → {Promise}
- Description:
Filter the table's rows according to the given filter function. Setting
therowFilterFunctiontonullwill remove the current filter and
reset the table model to display all rows.Will trigger a
rowsFilteredtinyevent.Remember that
Array#filteris synchronous, so if the filter needs to use
any data that is asynchronously retrieved, the async work must be performed
before the filter so that the filter function can work synchronously.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
rowFilterFunction |
function | standard array filter function |
Throws:
-
if a non-Function is given
- Type
- Error
Returns:
to be resolved after any necessary post-filtering work (this does not make
the filtering itself asynchronous).
- Type
- Promise
sort(sortFunction) → {Promise}
- Description:
Sort the table's rows according to the given sort function. Emits a
rowsReorderedevent.Remember that
Array#sortis 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.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
sortFunction |
function | standard array sort function to receive |
Throws:
-
if a non-Function is given
- Type
- Error
Returns:
to be resolved after any necessary post-sorting work (this does not make
the sorting itself asynchronous).
- Type
- Promise
(static) getColumns(flagsopt) → {Array.<module:nmodule/webEditors/rc/wb/mgr/model/MgrColumn>}
- Description:
Get the columns contained in this
MgrModel.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
flags |
Number |
<optional> |
if given, only return columns that have these |
Returns:
- Type
- Array.<module:nmodule/webEditors/rc/wb/mgr/model/MgrColumn>