Aras Innovator Platform

Public methods

loadData

Initializes the grid with specified rows and columns.

If the “columns” parameter is not specified, the columns will be obtained automatically from the “rows” parameter. Each unique property of the row object will represent a column with the same name.

If both the “rows” and “columns” parameters are not specified, the method removes all existing rows and columns.

Note
The grid automatically updates the corresponding properties of the provided row object when the cell value is changed.

Table 11: Optional Input parameters for loadData

NameTypeDescription
rowsArrayAn array containing the row objects described in section Row object. If the parameter is not an array, the rows are not added.
columnsArrayAn array containing column objects described in section Column object. The Array’s element position determines the column order.

Return value

Array – an array that contains the IDs of the added rows.

Example of the “rows” array parameter:

[

{

property1: ‘row 1’,

property2: ‘value2’,

someOtherProperties: ‘additional property’

},

{

property1: ‘row 2’

}

]

Example of the “columns” array parameter:

 [

{

label: ‘Column 1’,

width: 55,

name: ‘property1,

metadata: {

formatter: ‘select’,

editor: ‘select’, 

options:     [
                                            

{label: 'Red', value: 'id1'}, 

{label: 'Green', value: 'id2'}, 

{label: 'Blue', value: 'id3'}

]

}

},

{

name: ‘property2’,

settings: {

resizable: false,

sortable: true,

editable: false

}

}

]

obtainRowID

obtainRowID is an overridable handler which should return a unique row id for the given row object when adding new rows using the “loadData” or “addRows” methods. It returns null by default. The Unique row id will be generated automatically if the handler returns a falsy value, e.g., false, empty string, null or undefined. If the handler returns a truthy value which is not a string or grid that already contains a row with the same id, an error will be thrown in the “loadData” or “addRows” methods.

Table 12: Input parameters for obtainRowID

NameTypeDescription
rowInfoObjectRow object which is used to add a new row.
parentIdStringParent row ID. The ID will be Null if the row is added as root.

Return value

   String—<span class="bold">row ID.</span>
                                            
                                            Example:
                                            dynamicTreeGrid.obtainRowId = function(rowObj, parentId) {     return rowObj.id_property;
                                            };


addRows

Adds rows to the specified position in the grid. Table 13: Input parameters for addRows

Name Type Description
rowsArrayRequired parameter. Arrays containing row objects are described in section Row object. If the parameter is not an array, the rows will not be added.
parentIdStringOptional parameter. ID of the parent row. If the “parentId” parameter is null or undefined, rows will be added as roots.
positionNumberOptional parameter. It is a zero-based index that is used to insert new rows into the child row IDs array of the parent row (or roots array if parentId is not specified). The Index can be greater than or equal to 0 and less than or equal to the children array length. If the “position” parameter is not specified, new child rows will be appended to the end of the children array. The getChildRowIds method can be used to find out the row index in the children array.
doRenderBooleanOptional parameter. Renders grid after adding rows. The default value is true.

Return value Array—array which contains IDs of the added rows.

removeRow

Removes the row with the specified ID from the grid and grid rows collection. Table 14: Input parameters for removeRows

NameTypeDescription
rowIdStringRow ID.

removeAllRows

Removes all rows from the grid and the grid rows collection.

selectRow

Selects the row with the specified ID. Otherwise, the specified row becomes selected, and all previously selected rows stay selected. Table 15: Input parameters for selectRow

NameTypeDescription
rowIdStringRow ID.

deselectRow

Cancels the selection of the specified row. Table 16: Input parameters for deselectRow

NameTypeDescription
rowIdStringRow ID.

addColumn

Adds a column to the grid. Table 17: Input parameters for addColumn

Name Type Description
columnObjectRequired parameter. The Column object is described in the section Column object.
positionNumberOptional parameter. Zero based column index. If its position is not specified, the column will be appended after existing columns.

removeColumn

Removes the specified column from the grid and the grid columns collection. Table 18: Input parameters for removeColumn

NameTypeDescription
nameStringColumn name.

getChildRowIds

Returns an Array containing the child row IDs for the specified parent row. This method returns the IDs of the root rows if the “parentId” parameter is null or undefined. Table 19: Input parameters for getChildRowIds

NameTypeDescription
parentIdStringOptional parameter. ID of the parent row.

Return value Array—array with child row IDs or an empty array if there are no children.

getRowUserData

Gets user data stored by the specified row and key. Table 20: Input parameters for getRowUserData

NameTypeDescription
rowIdStringRow ID.
keyStringKey for storing user data.

Return value Anything—user data stored by the specified row and key. Example: let itemtype = grid.getRowUserData(rowId, ‘itemtype’);

setRowUserData

Sets user data for the specified row and key. Table 21: Input parameters for setRowUserData

NameTypeDescription
rowIdStringRow ID
keyStringKey for storing user data
valueAnythingValue

Example: grid.setRowUserData(rowId, ‘itemtype’, ‘Part’);

setCellEditability

Sets cell edit availability. Table 22: Input parameters for setCellEditability

NameTypeDescription
rowIdStringRequired parameter. Row ID.
columnNameStringRequired parameter. Column name.
editableBooleanOptional parameter. Can a cell be edited or not? Default value is true.

getCellEditability

Returns true if the specified cell is editable, otherwise it returns false. Table 23: Input parameters for getCellEditability

Name Type Description
rowIdStringRow ID.
columnNameStringColumn name.

Return value Boolean—is cell editable or not.

setCellValue

Sets cell value and updates the corresponding property in the user row object. Table 24: Input parameters for setCellValue

NameTypeDescription
rowIdStringRow ID
columnNameStringColumn name
valueAnythingCell value

getCellValue

Gets the cell value. Table 25: Input parameters for getCellValue

NameTypeDescription
rowIdStringRow ID
columnNameStringColumn name

Return value Anything—cell value.

getColumnCount

Gets a count of all columns (visible and invisible). Return value Number

getVisibleColumnCount

Gets a count of visible columns. Return value Number

getColumnIndex

Gets a column index by the column name. Returns -1 if the column is not found or is invisible. Table 26: Input parameters for getColumnIndex

NameTypeDescription
columnNameStringColumn name.

Return value Number—column index

getColumnName

Gets the column name using the column index. Table 27: Input parameters for getColumnName

NameTypeDescription
columnIndexNumberColumn index

Return value String—column name

getColumnOrder

Gets Array with the names of visible columns in the same order as they are displayed in the grid. Return value Array

getAllColumnNames

Gets Array with the names of all columns in the order they are added to the grid. Return value Array

getParentId

Gets the ID of the parent row for the specified row. Returns null if the specified row is root and has no parent. Table 28: Input parameters for getParentId

NameTypeDescription
rowIdStringRow ID.

Return value String—parent row ID.

containsRow

Returns true if the grid has a row with the specified ID in the rows collection, otherwise it returns false. Table 29: Input parameters for containsRow

NameTypeDescription
rowIdStringRow ID.

Return value Boolean

containsColumn

Returns true if the grid has a column with the specified name in the columns collection, otherwise it returns false. Table 30: Input parameters for containsColumn

NameTypeDescription
columnNameStringColumn name.

Return value Boolean

expandAll

Expands all rows with their descendants.

collapseAll

Collapses all rows with their descendants.

isRowExpanded

Returns true if the specified row is expanded, otherwise it returns false. Table 31: Input parameters for isRowExpanded

NameTypeDescription
rowIdStringRow ID.

Return value Boolean

isRowVisible

Returns true if the specified row is visible, otherwise it returns false. Table 32: Input parameters for isRowVisible

NameTypeDescription
rowIdStringRow ID.

Return value Boolean

getVisibleRowCount

Gets the number of visible rows that can be displayed in the grid.

Note
The number of visible rows is not the total rows count. For example, if the grid has only one root row with 10 children and the root row is collapsed, the getVisibleRowCount() method will return 1.

Return value Number

getAllRowCount

Gets the number of all rows (visible and invisible) contained in the rows collection. Return value Number

getVisibleRowIds

Gets the Array with the IDs of visible rows displayed in the grid. Return value Array

getAllRowIds

Gets the Array with the IDs of all rows contained in the rows collection. Return value Array

getRowId

Gets the row ID by the row index. Table 33: Input parameters for getRowId

NameTypeDescription
rowIndexNumberRow index (zero based, from “top” to “bottom”).

Return value String—row ID.

getRowIndex

Gets the row index using the row ID. The method returns -1 if the row is not found or not visible. Table 34: Input parameters for getRowIndex

NameTypeDescription
rowIdStringRow ID

Return value Number—row index.

moveColumn

Moves a column to the specified position. Table 35: Input parameters for moveColumn

NameTypeDescription
columnNameStringColumn name
columnIndexNumberNew column position – zero based index.

setColumnSettings

Sets settings for the specified column. Table 36: Input parameters for setColumnSettings

Name Type Description
columnNameStringColumn name
settingsObjectThe Column settings object described in the section Column settings object.
Note
Note: If a column setting is not specified in the column object, its value will not bechanged.

getColumnSettings

Gets settings for the specified column. Table 37: Input parameters for getColumnSettings

NameTypeDescription
columnNameStringColumn name.

Return value Object—column settings object described in section Column settings object.

setColumnMetadata

Sets metadata for the specified column that will be used by the column cells without their own metadata. Table 38: Input parameters for setColumnMetadata

NameTypeDescription
columnNameStringColumn name
metadataObjectMetadata object described in the section Metadata objects.

getColumnMetadata

Gets metadata for the specified column. Returns null if the column has no metadata. Table 39: Input parameters for getColumnMetadata

NameTypeDescription
columnNameStringColumn name

Return value Object—metadata object described in section Metadata objects.

setColumnVisibility

Sets column visibility. Table 40: Input parameters for setColumnVisibility

NameTypeDescription
columnNameStringRequired parameter. Column name.
visibleBooleanOptional parameter. Column visibility. The default value is true.

getColumnVisibility

Returns true if the specified column is visible, otherwise it returns false. Table 41: Input parameters for getColumnVisibility

NameTypeDescription
columnNameStringColumn name

Return value Boolean

setColumnLabel

Sets the label for the specified column. Table 42: Input parameters for setColumnLabel

Name Type Description
columnNameStringColumn name
labelStringColumn label.

getColumnLabel

Gets the label for the specified column. Table 43: Input parameters for getColumnLabel

NameTypeDescription
columnNameStringColumn name

Return value String—column label.

setColumnWidth

Sets the width for the specified column. Table 44: Input parameters for setColumnWidth

NameTypeDescription
columnNameStringColumn name
widthNumberColumn width

getColumnWidth

Gets the width for the specified column. Table 45: Input parameters for getColumnWidth

NameTypeDescription
columnNameStringColumn name

Return value Number—column width.

setCellMetadata

Sets metadata for the specified cell. Table 46: Input parameters for setCellMetadata

NameTypeDescription
rowIdStringRow ID
columnNameStringColumn name
metadataObjectMetadata object described in the section 10.4.1

getCellMetadataOnly

Gets metadata for the specified cell. Returns null if the cell has no metadata (even if the column has metadata). Table 47: Input parameters for getCellMetadataOnly

NameTypeDescription
rowIdStringRow ID
columnNameStringColumn name

Return value Object—metadata object described in section Metadata objects.