Public methods
Copy
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.
Table 11: Optional Input parameters for loadData
| Name | Type | Description |
| rows | Array | An array containing the row objects described in section Row object. If the parameter is not an array, the rows are not added. |
| columns | Array | An 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
| Name | Type | Description |
| rowInfo | Object | Row object which is used to add a new row. |
| parentId | String | Parent 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 |
| rows | Array | Required parameter. Arrays containing row objects are described in section Row object. If the parameter is not an array, the rows will not be added. |
| parentId | String | Optional parameter. ID of the parent row. If the “parentId” parameter is null or undefined, rows will be added as roots. |
| position | Number | Optional 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. |
| doRender | Boolean | Optional 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
| Name | Type | Description |
| rowId | String | Row 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
| Name | Type | Description |
| rowId | String | Row ID. |
deselectRow
Cancels the selection of the specified row. Table 16: Input parameters for deselectRow
| Name | Type | Description |
| rowId | String | Row ID. |
addColumn
Adds a column to the grid. Table 17: Input parameters for addColumn
| Name | Type | Description |
| column | Object | Required parameter. The Column object is described in the section Column object. |
| position | Number | Optional 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
| Name | Type | Description |
| name | String | Column 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
| Name | Type | Description |
| parentId | String | Optional 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
| Name | Type | Description |
| rowId | String | Row ID. |
| key | String | Key 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
| Name | Type | Description |
| rowId | String | Row ID |
| key | String | Key for storing user data |
| value | Anything | Value |
Example: grid.setRowUserData(rowId, ‘itemtype’, ‘Part’);
setCellEditability
Sets cell edit availability. Table 22: Input parameters for setCellEditability
| Name | Type | Description |
| rowId | String | Required parameter. Row ID. |
| columnName | String | Required parameter. Column name. |
| editable | Boolean | Optional 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 |
| rowId | String | Row ID. |
| columnName | String | Column 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
| Name | Type | Description |
| rowId | String | Row ID |
| columnName | String | Column name |
| value | Anything | Cell value |
getCellValue
Gets the cell value. Table 25: Input parameters for getCellValue
| Name | Type | Description |
| rowId | String | Row ID |
| columnName | String | Column 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
| Name | Type | Description |
| columnName | String | Column name. |
Return value Number—column index
getColumnName
Gets the column name using the column index. Table 27: Input parameters for getColumnName
| Name | Type | Description |
| columnIndex | Number | Column 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
| Name | Type | Description |
| rowId | String | Row 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
| Name | Type | Description |
| rowId | String | Row 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
| Name | Type | Description |
| columnName | String | Column 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
| Name | Type | Description |
| rowId | String | Row ID. |
Return value Boolean
isRowVisible
Returns true if the specified row is visible, otherwise it returns false. Table 32: Input parameters for isRowVisible
| Name | Type | Description |
| rowId | String | Row ID. |
Return value Boolean
getVisibleRowCount
Gets the number of visible rows that can be displayed in the grid.
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
| Name | Type | Description |
| rowIndex | Number | Row 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
| Name | Type | Description |
| rowId | String | Row ID |
Return value Number—row index.
moveColumn
Moves a column to the specified position. Table 35: Input parameters for moveColumn
| Name | Type | Description |
| columnName | String | Column name |
| columnIndex | Number | New column position – zero based index. |
setColumnSettings
Sets settings for the specified column. Table 36: Input parameters for setColumnSettings
| Name | Type | Description |
| columnName | String | Column name |
| settings | Object | The 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
| Name | Type | Description |
| columnName | String | Column 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
| Name | Type | Description |
| columnName | String | Column name |
| metadata | Object | Metadata 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
| Name | Type | Description |
| columnName | String | Column name |
Return value Object—metadata object described in section Metadata objects.
setColumnVisibility
Sets column visibility. Table 40: Input parameters for setColumnVisibility
| Name | Type | Description |
| columnName | String | Required parameter. Column name. |
| visible | Boolean | Optional 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
| Name | Type | Description |
| columnName | String | Column name |
Return value Boolean
setColumnLabel
Sets the label for the specified column. Table 42: Input parameters for setColumnLabel
| Name | Type | Description |
| columnName | String | Column name |
| label | String | Column label. |
getColumnLabel
Gets the label for the specified column. Table 43: Input parameters for getColumnLabel
| Name | Type | Description |
| columnName | String | Column name |
Return value String—column label.
setColumnWidth
Sets the width for the specified column. Table 44: Input parameters for setColumnWidth
| Name | Type | Description |
| columnName | String | Column name |
| width | Number | Column width |
getColumnWidth
Gets the width for the specified column. Table 45: Input parameters for getColumnWidth
| Name | Type | Description |
| columnName | String | Column name |
Return value Number—column width.
setCellMetadata
Sets metadata for the specified cell. Table 46: Input parameters for setCellMetadata
| Name | Type | Description |
| rowId | String | Row ID |
| columnName | String | Column name |
| metadata | Object | Metadata 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
| Name | Type | Description |
| rowId | String | Row ID |
| columnName | String | Column name |
Return value Object—metadata object described in section Metadata objects.