LyteNyte Grid's imperative API is primarily used to query the grid for metadata or perform operations that require more nuanced behavior when handled declaratively, such as re-ordering columns. This page outlines all available API methods.
The LyteNyte Grid interfaces follow a naming convention designed to improve the
developer experience. Methods are prefixed with the category the API applies to. For example,
all cell editing API methods are prefixed with cellEdit
, such as cellEditBegin
and cellEditEnd
.
This convention has implications for how you use the API. For instance, to retrieve a column by its id
,
the method is columnById
. Other libraries might name this method getColumnById
. However, this latter approach
doesn't aid in API discoverability, which is why LyteNyte Grid opted for category prefixing.
Throughout this reference, you will see Column
and Api
type parameters. The actual type depends
on the edition of LyteNyte being used: ColumnPro
for the PRO edition and ColumnCore
for the Core
edition. The API documentation will clearly indicate when a feature is only available in the PRO edition.
The types for autosizing are:
interface AutosizeOptions {
readonly dryRun?: boolean;
readonly includeHeader?: boolean;
}
interface AutosizeResult {
readonly [columnId: string]: number;
}
autosizeColumn
Autosizes a single column to fit its content. The size calculation depends
on the cellAutosizeFn
property of the column being autosized. The method returns an
AutosizeResult
value or null
if the column is not defined.
The autosizeColumn
method accepts an options
object as
the second parameter. If dryRun
is set to true, the autosize calculation will be performed and returned, but will
not be applied to the grid state. If the includeHeader
property is set to true, the contents of the column's
header will be considered when autosizing. The headerAutosizeFn
property on the column will be used to calculate
the size of the header.
autosizeColumns
Autosizes a list of columns or all columns in the grid. The size calculation depends on the cellAutosizeFn
property of the columns being autosized. The method returns an AutosizeResult
value or null
if the columns
provided are not defined.
The autosizeColumns
method accepts an options
object as the second parameter.
If dryRun
is set to true, the autosize calculation will be performed and returned, but will
not be applied to the grid state. If the includeHeader
property is set to true, the contents of the column's
header will be considered when autosizing. The headerAutosizeFn
property on the column will be used to calculate
the size of the header.
When autosizing all columns, columns with cellSkipOnAutosizeAll
set to true will be skipped.
autosizeMeasure
Calculates the Text Metrics for the given text,
and optionally applies the specified font
style. This method is primarily useful for creating custom autosize functions
for columns. It uses a canvas
element to compute the size metrics. In server environments, the method will
return null
.
The types for cell editing are:
type CellEditLocation = {
readonly rowIndex: number;
readonly columnIndex: number;
};
cellEditBegin
Begins a cell edit for a specified cell. If the makeActive
parameter is set to true, then LyteNyte Grid will make the
cell edit active (which typically means the cell will receive focus).
This method is typically not called directly unless you're implementing a custom edit integration for cell editing. The LyteNyte Grid components use this API method internally to support cell editing functionality.
cellEditEnd
Ends cell editing for the provided cell location. Ending a cell edit will apply the edit value to the cell in the grid.
If the cancel
flag is set to true
, the cell edit will not be applied.
This method is typically not called directly unless you're implementing a custom edit integration for cell editing. The LyteNyte Grid components use this API method internally to support cell editing functionality.
cellEditValue
Returns the current cell edit value, which is distinct from the cell's actual value. The cell maintains its original value until the cell edit value is applied.
This method is typically not called directly unless you're implementing a custom edit integration for cell editing. The LyteNyte Grid components use this API method internally to support cell editing functionality.
cellEditSetValue
Sets the cell edit value for the given cell location. This is the 'setValue' method for cell editing. This method does not apply the cell edit value to the cell being edited - it only updates the pending edit value.
This method is typically not called directly unless you're implementing a custom edit integration for cell editing. The LyteNyte Grid components use this API method internally to support cell editing functionality.
cellEditIsValueValid
Returns true
if the current edit value is valid. This is normally used to provide error indications in cell edit
providers. A valid value may be applied to a cell. If the value is invalid, the cell will not accept the edit.
This method is typically not called directly unless you're implementing a custom edit integration for cell editing. The LyteNyte Grid components use this API method internally to support cell editing functionality.
cellEditPredicate
Returns true
if a cell may be edited. This is useful for determining whether a cell edit interaction can take place.
cellEditIsActive
Returns true
if there is an active cell edit in progress. This is useful for determining if the user is currently editing
a value in the grid.
columnField
Returns the field value for a given row and column. This method is used to extract the value from a row's data for a specific column.
columnFieldGroup
Returns the field value for a given leaf row node and column. This is specifically used for handling grouped data rows.
columnGroupToggle
Toggles the expanded state of a column group. If the optional state
parameter is provided,
the group will be set to that state directly; otherwise, the current state will be toggled.
columnVisualWidth
Returns the visual width of a column in pixels. This is the width that is actually displayed in the grid, which may differ from the column's configured width due to factors like minimum width constraints or flex configurations.
columnUpdate
Updates a single column with the provided properties. This method allows you to modify column
properties without replacing the entire column definition. The id
property cannot be changed with this method.
columnUpdateMany
Updates multiple columns in a single operation. The keys of the updates
object should be column ids,
and the values should be the properties to update for each column. Similar to columnUpdate
, the id
property cannot be changed.
columnMoveAfter
Moves one or more columns to a position after the specified destination column. This is used for reordering columns in the grid.
columnMoveBefore
Moves one or more columns to a position before the specified destination column. This is used for reordering columns in the grid.
columnMoveToVisibleIndex
Moves one or more columns to a specific visible index position. The optional before
parameter
determines whether the columns are placed before or after the index position.
columnResize
Resizes a column to the specified width in pixels. This method will respect any minimum and maximum width constraints defined on the column.
columnResizeMany
Resizes multiple columns in a single operation. The keys of the columns
object
should be column ids, and the values should be the new widths in pixels for each column.
columnById
Retrieves a column by its id. Returns undefined
if no column with the specified id exists.
columnByIndex
Retrieves a column by its index position in the grid. Returns undefined
if the index is out of range.
columnIndex
Returns the index position of a given column in the grid. Returns null
if the column is not found in the grid.
columnIsResizable
Returns true
if the column can be resized by the user. This takes into account
both the column's own configuration and any grid-level settings that might affect resizability.
columnIsSortable
Returns true
if the column can be sorted by the user. This takes into account both the
column's own configuration and any grid-level settings that might affect sortability.
columnIsMovable
Returns true
if the column can be moved/reordered by the user. This takes into
account both the column's own configuration and any grid-level settings that might affect movability.
columnIsHidable
Returns true
if the column can be hidden by the user. This takes into account both
the column's own configuration and any grid-level settings that might affect hidability.
columnIsEmpty
Returns true
if the column is the auto-generated empty column in the grid. The empty column is created
when a column group is collapsed and there are not visible columns for that group when it is collapsed.
columnIsMarker
Returns true
if the column is the marker column. The marker column is a special-purpose column that allows operations like
checkbox row selection or row dragging.
columnIsGroupAutoColumn
Returns true
if the column is an automatically generated group column.
These columns are typically created by the grid when grouping functionality is enabled.
columnIsGridGenerated
Returns true
if the column was automatically generated by the grid rather than
explicitly defined by the user. This includes various utility columns that the grid might create.
columnIsRowGroupable
Returns true
if the column can be used for row grouping.
This typically means the column contains categorical data suitable for grouping rows.
columnIsEditable
Returns true
if the column's cells can be edited by the user.
This takes into account both the column's own configuration
and any grid-level settings that might affect editability.
columnIsVisible
Returns true
if the column is currently visible in the grid. If
the optional ignoreGroupVisibility
parameter is set to true
, the visibility
of parent groups will not be considered when determining the column's visibility.
columnActiveAgg
Returns the active aggregation model for the column, or null
if no aggregation
is active. This is used for columns that display aggregated values when grouping is enabled.
columnSortModelIndex
Returns the index of the column in the current sort model. This can be used to determine the sorting priority when multiple columns are being sorted simultaneously.
columnSortCycle
Returns the sort cycle options for the column, or null
if the column doesn't
support sorting. The sort cycle defines the sequence of sort states
(e.g., none → ascending → descending) that the column cycles through when sorted.
columnSortCycleIndex
Returns the current index in the sort cycle for the column, or null
if the column
isn't currently in the sort model. This can be used to determine the
current sort state within the column's sort cycle.
columnSortDirection
Returns the current sort direction for the column: "asc"
for
ascending, "desc"
for descending, or null
if the column isn't currently sorted.
columnSortGetNext
Returns the next sort cycle option for the column, or null
if the column doesn't
support sorting. This is useful for previewing what the next sort state would be without actually applying it.
columnSortCycleToNext
Advances the column's sort state to the next option in its sort cycle. If the
optional additive
parameter is true
, the column will be added to the existing
sort model rather than replacing it, allowing for multi-column sorting.
columnInFilterItems
Retrieves the list of filter items available for a specific column. This function returns either an
array of ColumnInFilterItem
objects or a Promise that resolves to such an array.
These items represent the distinct values or predefined filters that can be applied to the column.
This is particularly useful for populating filter dropdown menus or creating custom filter interfaces. The returned items typically include information such as the display value, the actual value for filtering, and possibly additional metadata.
columnIsMeasurable
Determines whether a column can be used as a measure in aggregations or pivot tables. This function returns a boolean value indicating if the column contains numeric or otherwise quantifiable data that can be meaningfully aggregated (summed, averaged, etc.).
Measurable columns are typically those containing numeric values, dates, or other data types that can be processed with mathematical operations. This information is useful for building user interfaces that present appropriate options for analytics features.
columnQuickSearchField
Extracts a searchable value from a row for a specific column. This function is used during quick search operations to determine the value that should be matched against the search query.
The returned value might be different from the displayed value in the cell, as it could be processed to facilitate better search matching (e.g., normalized text, extracted components from complex objects). This function is essential for implementing efficient and accurate search functionality across grid data.
columnIsPivotable
Determines whether a column can be used in pivot operations. This function returns a boolean value indicating if the column can serve as a row field, column field, or filter field in a pivot table.
Pivotable columns typically contain categorical or discrete data that can be used to organize and group information meaningfully. This information is useful for building user interfaces that present appropriate options for pivot table configuration.
columnActiveAgg
Returns the active aggregation model for a column, or null
if no aggregation
is active. The aggregation model defines how values in the column are
combined when grouped (e.g., sum, average, count).
This function is useful for determining the current aggregation state of a column, which can be important when displaying aggregated data or configuring analytics features. The returned value is a string identifier that corresponds to a specific aggregation method.
columnActiveMeasure
Returns the active measure being used for a column in aggregations or pivot tables. The measure defines which value is being aggregated when the column is used in analytical operations.
Unlike columnActiveAgg
which returns the aggregation method, this function returns the measure
(the value being aggregated). This is particularly relevant for columns that
might aggregate different fields or apply different transformations before aggregation.
The types for exporting are:
interface DataRect {
readonly rowStart: number;
readonly rowEnd: number;
readonly columnStart: number;
readonly columnEnd: number;
}
interface ExportTransformDataRowParams {
readonly api: API;
readonly columns: Column[];
readonly data: unknown[];
}
type ExportTransformDataRow = (p: ExportTransformDataRowParams) => unknown[];
interface ExportCsvOptions {
readonly includeHeader?: boolean;
readonly includeGroupHeaders?: boolean;
readonly uniformGroupHeaders?: boolean;
readonly delimiter?: "," | ";" | "\t" | (string & {});
readonly transform?: ExportTransformDataRow;
readonly dataRect?: DataRect;
}
interface ExportDataRectOptions {
readonly dataRect?: DataRect;
readonly transform?: ExportTransformDataRow;
readonly uniformGroupHeaders?: boolean;
}
interface DataRectResult {
readonly header: string[];
readonly groupHeaders: (string | null)[][];
readonly data: unknown[][];
readonly columns: Column[];
}
exportDataRect
Exports a rectangular selection of data from the grid. This method provides access to the raw data structure, which can be useful for custom export implementations or for processing grid data before export.
The optional options
parameter allows you to specify:
dataRect
propertyThe result includes header information, group headers, the actual data rows, and a reference to the columns included in the export.
exportCsv
Exports grid data as a CSV-formatted string. This method allows for flexible configuration of the export format through the optional options
parameter.
Options include:
includeHeader
)includeGroupHeaders
)uniformGroupHeaders
)This method returns a string containing the CSV data, or a Promise that resolves to the CSV string for asynchronous exports.
exportCsvFile
Exports grid data as a CSV file in the form of a Blob object, which can be used to save the data to the user's device. This method accepts the same options as exportCsv
, allowing for flexible configuration of the export format.
The returned Promise resolves to a Blob containing the CSV data with the appropriate MIME type, which can be used with browser APIs like URL.createObjectURL()
or the File System Access API to save the file.
This method is particularly useful for client-side applications that need to provide a "Download CSV" functionality without requiring server involvement.
The types for navigation are:
type PositionGridCellKind = 1;
type PositionFullWidthKind = 2;
type PositionHeaderCellKind = 3;
type PositionHeaderGroupCellKind = 4;
type PositionFloatingCellKind = 5;
type PositionGridCell = {
readonly kind: PositionGridCellKind;
readonly columnIndex: number;
readonly rowIndex: number;
readonly root: {
columnIndex: number;
rowIndex: number;
rowSpan: number;
columnSpan: number;
} | null;
};
type PositionFullWidthRow = {
readonly kind: PositionFullWidthKind;
readonly columnIndex: number;
readonly rowIndex: number;
};
type PositionHeaderCell = {
readonly kind: PositionHeaderCellKind;
readonly columnIndex: number;
};
type PositionHeaderGroupCell = {
readonly kind: PositionHeaderGroupCellKind;
readonly columnStartIndex: number;
readonly columnEndIndex: number;
readonly columnIndex: number;
readonly hierarchyRowIndex: number;
};
type PositionFloatingCell = {
readonly kind: PositionFloatingCellKind;
readonly columnIndex: number;
};
type Position =
| PositionGridCell
| PositionFloatingCell
| PositionHeaderCell
| PositionFullWidthRow
| PositionHeaderGroupCell;
type PositionFocus = {
kind: "cell";
rowIndex: number;
columnIndex: number;
};
navigateNext
Navigates to the next cell position in the grid, typically moving from left to right, and then to the next row when reaching the end of the current row. This method updates the current navigation position in the grid.
navigatePrev
Navigates to the previous cell position in the grid, typically moving from right to left, and then to the previous row when reaching the start of the current row. This method updates the current navigation position in the grid.
navigateUp
Navigates to the cell directly above the current position in the grid. This method updates the current navigation position in the grid, maintaining the same column while decreasing the row index.
navigateDown
Navigates to the cell directly below the current position in the grid. This method updates the current navigation position in the grid, maintaining the same column while increasing the row index.
navigateToStart
Navigates to the first cell in the current row. This method updates the current navigation position in the grid, maintaining the same row while setting the column index to the first visible column.
navigateToEnd
Navigates to the last cell in the current row. This method updates the current navigation position in the grid, maintaining the same row while setting the column index to the last visible column.
navigateToTop
Navigates to the first row in the grid while maintaining the current column. This method updates the current navigation position in the grid, setting the row index to the first visible row.
navigateToBottom
Navigates to the last row in the grid while maintaining the current column. This method updates the current navigation position in the grid, setting the row index to the last visible row.
navigatePageDown
Navigates one page down in the grid, moving the current position by approximately the number of rows visible in the viewport. This method updates the current navigation position in the grid.
navigatePageUp
Navigates one page up in the grid, moving the current position by approximately the number of rows visible in the viewport. This method updates the current navigation position in the grid.
navigateGetNext
Calculates and returns the next position in the grid without actually navigating
to it. This method returns a Position
object representing the next cell, or null
if
there is no valid next position.
navigateGetPrev
Calculates and returns the previous position in the grid without
actually navigating to it. This method returns a Position
object
representing the previous cell, or null
if there is no valid previous position.
navigateGetUp
Calculates and returns the position directly above the current position
in the grid without actually navigating to it. This method returns a Position
object
representing the cell above, or null
if there is no valid position above.
navigateGetDown
Calculates and returns the position directly below the current position in
the grid without actually navigating to it. This method returns a Position
object representing the cell below, or null
if there is no valid position below.
navigateGetPageDown
Calculates and returns the position that would result from a page down
operation without actually navigating to it. This method returns a Position
object representing the page down destination, or null
if there is no valid position.
navigateGetPageUp
Calculates and returns the position that would result from a page up operation without
actually navigating to it. This method returns a Position
object representing the
page up destination, or null
if there is no valid position.
navigateGetStart
Calculates and returns the position of the first cell in the current row without
actually navigating to it. This method returns a Position
object
representing the first cell in the row, or null
if there is no valid position.
navigateGetEnd
Calculates and returns the position of the last cell in the current row without
actually navigating to it. This method returns a Position
object representing the
last cell in the row, or null
if there is no valid position.
navigateGetTop
Calculates and returns the position of the cell in the first row, maintaining
the current column, without actually navigating to it. This method returns a
Position
object representing the cell at the top of the grid, or null
if there is no valid position.
navigateGetBottom
Calculates and returns the position of the cell in the last row, maintaining
the current column, without actually navigating to it. This method returns a
Position
object representing the cell at the bottom of the grid, or null
if there is no valid position.
navigateScrollIntoView
Scrolls the grid viewport to ensure that the cell at the specified row and column
indices is visible. If either parameter is omitted or null
, the current
navigation position's corresponding index is used. This method adjusts the
grid's scroll position without changing the current navigation position.
navigateSetPosition
Sets the current navigation position in the grid to the specified Position
object.
If null
is provided, the current navigation position is cleared. This method
allows for direct positioning of the navigation focus to any valid location in the grid.
navigateGetPosition
Returns the current navigation position in the grid as a Position
object, or null
if there is no current position. This method is useful for saving and
restoring the user's position within the grid.
paginateRowStartAndEndForPage
Calculates the start and end row indices for a specified page number. This method is essential for implementing pagination in the grid, as it determines which rows should be displayed for a given page.
The function takes a page number (zero-based) as input and returns a tuple containing two numbers: the first is the index of the first row on that page, and the second is the index of the last row on that page. These indices are inclusive and can be used to slice the data array or to set viewport boundaries.
The calculation takes into account the current pagination settings of the grid, such as the number of rows per page. If the requested page is out of range (e.g., beyond the total number of pages), the function will still return valid indices, typically representing an empty range.
rowDetailIsExpanded
Checks if the detail section for a specific row is currently expanded. This function accepts the row's unique identifier and returns a boolean value indicating the expansion state.
rowDetailToggle
Toggles the expansion state of a row's detail section. This function accepts the row's unique identifier and an optional boolean parameter to explicitly set the expansion state. If the second parameter is omitted, the current state will be toggled (expanded rows will collapse and collapsed rows will expand).
rowDetailRowPredicate
Determines whether a specific row can display a detail section. This function accepts the row's unique identifier and returns a boolean indicating if the row supports detailed view expansion.
rowDetailVisibleHeight
Returns the current visible height (in pixels) of the detail section for a specific row. If the detail section is collapsed, this will return 0. This function is useful for layout calculations that need to account for expanded row details.
rowSelectionGetSelected
Returns an array of all currently selected row nodes. This function provides access to the complete selection state of the grid, allowing you to retrieve all selected rows at once.
rowSelectionSelect
Selects one or more rows identified by their unique IDs. The function accepts an array of row IDs to select and an optional boolean parameter that determines whether child rows should also be selected when selecting a group row. This is particularly useful for hierarchical data structures.
rowSelectionDeselect
Deselects one or more rows identified by their unique IDs. The function accepts an array of row IDs to deselect and an optional boolean parameter that determines whether child rows should also be deselected when deselecting a group row. This is particularly useful for hierarchical data structures.
rowSelectionIsIndeterminate
Checks if a group row has an indeterminate selection state, meaning some but not all of its children are selected. This function is primarily used with hierarchical data to determine the appropriate visual state for group row selection indicators.
rowSelectionAllRowsSelected
Returns a boolean indicating whether all rows in the grid are currently selected. This function is useful for implementing "select all" functionality with proper state tracking.
rowSelectionSelectAll
Selects all rows in the grid. This function provides a convenient way to implement "select all" functionality with a single method call.
rowSelectionClear
Clears all row selections, deselecting all currently selected rows. This function provides a convenient way to reset the selection state of the grid with a single method call.
rowSelectionSelectAllSupported
Returns a boolean indicating whether "select all" functionality is supported for the current grid configuration. This may depend on factors such as the selection mode, the data structure, or other grid settings.
rowIsGroup
A type guard function that checks if a row node is a group row. Returns
true if the row is a group, and narrows the type to RowNodeGroup
for TypeScript
type checking. This is useful when working with hierarchical data structures in the grid.
rowIsLeaf
A type guard function that checks if a row node is a leaf row (i.e., not a group).
Returns true if the row is a leaf, and narrows the type to RowNodeLeaf<D>
for TypeScript type checking. This is useful when working with hierarchical data structures in the grid.
rowIsDraggable
Determines whether a specific row can be dragged by the user. This function accepts the row's unique identifier and returns a boolean indicating if the row supports dragging operations, based on the current grid configuration and row properties.
rowVisibleRowHeight
Returns the current visible height (in pixels) of a specific row at the given index. This takes into account row details, grouping, and any other factors that might affect the row's height. An optional section parameter can be provided to specify which section of rows to consider (e.g., header, body, footer).
rowGroupToggle
Toggles the expansion state of a group row. This function accepts a group row node and an optional boolean parameter to explicitly set the expansion state. If the second parameter is omitted, the current state will be toggled (expanded groups will collapse and collapsed groups will expand).
rowGroupIsExpanded
Checks if a group row is currently expanded. This function accepts any row node and returns a boolean indicating the expansion state. For non-group rows, this will typically return false.
rowUpdateRedo
Redoes the most recently undone row update operation, if available. This function is part of the grid's undo/redo system and allows you to reapply changes that were previously undone.
rowUpdateUndo
Undoes the most recent row update operation, if available. This function is part of the grid's undo/redo system and allows you to reverse recent changes to row data.
rowSetData
Updates the data for a specific row identified by its unique ID. This function allows you to modify a single row's data without affecting other rows or replacing the entire dataset.
rowSetDataMany
Updates the data for multiple rows in a single operation. This function accepts an object where the keys are row IDs and the values are the new data objects for those rows. This is more efficient than making multiple individual updates when changing several rows at once.
rowReplaceData
Replaces the entire dataset with a new array of data objects. This function completely replaces all existing rows with new data, effectively resetting the grid's content while maintaining the current configuration.
rowReplaceTopData
Replaces only the top-level data in the grid with a new array of data objects. This is particularly useful for hierarchical datasets where you want to update only the top level without affecting child rows.
rowReplaceBottomData
Replaces only the bottom-level data in the grid with a new array of data objects. This is particularly useful for hierarchical datasets or grids with pinned rows, where you want to update only the bottom rows without affecting other content.
rowReload
Reloads all row data in the grid. This function triggers a complete refresh of the grid's data structures and visual representation, ensuring that any changes to the underlying data are reflected in the grid.
This is particularly useful after making significant changes to the dataset outside of the grid's API methods, or when you need to ensure the grid is synchronized with external data sources. The reload operation preserves the current grid state such as selection, sorting, and filtering where possible.
rowReloadExpansion
Reloads the expansion state for a specific group row. This function is used to refresh the child rows of a group after the underlying data has changed, without reloading the entire grid.
This is particularly useful in scenarios with dynamic hierarchical data, where child rows might be added, removed, or modified while the grid is displayed. By targeting only the specific group that needs updating, this method is more efficient than a full grid reload.
rowReset
Resets the grid's row state to its initial configuration. This function clears all row-related modifications such as selections, expansions, and any custom state that might have been applied during user interaction.
Unlike rowReload
, which refreshes the data while preserving state, this method
explicitly discards state information and returns the grid to its default configuration. This can
be useful when implementing "Reset" functionality or when you need to
ensure a clean state before applying new settings.
eventAddListener
Registers an event listener for a specific grid event. This method allows you to attach callback functions that will be executed when certain events occur in the grid. The listener function receives event-specific parameters that provide context about the event that occurred.
The method follows a standard event registration pattern where you specify the event name and the callback function to be executed when that event occurs. The grid supports numerous events covering interactions like cell clicks, selection changes, column resizing, and more.
eventRemoveListener
Removes a previously registered event listener for a specific grid event. This method allows you
to detach callback functions that were previously attached using eventAddListener
. To
successfully remove a listener, you must provide the same event name and function reference that was used to register it.
eventGetListeners
Retrieves all registered event listeners for a specific event type. This method returns a Set containing
all the callback functions that have been registered for the specified
event, or null
if no listeners have been registered for that event.
This can be useful for debugging purposes or for implementing custom event handling logic that needs to know which listeners are currently active.
eventFire
Manually triggers a specific event with the provided arguments. This method allows you to programmatically fire events as if they had occurred naturally through user interaction or other grid operations.
The method takes the event name as its first parameter, followed by any additional arguments required by the event type. These arguments will be passed to all registered listeners for the specified event.
This can be useful for simulating user interactions or for creating custom behaviors that need to trigger standard grid events.
The types for cell selection are:
export interface CellSelectionRect {
readonly rowStart: number;
readonly rowEnd: number;
readonly columnStart: number;
readonly columnEnd: number;
}
cellSelectionIsSelected
Checks if a specific cell is currently selected. This function accepts row and column indices and returns a boolean indicating whether the cell at that position is part of the current selection.
cellSelectionExpandDown
Expands the current cell selection downward from a reference point. This function is typically used during interactive selection operations, such as when a user is extending a selection with the keyboard or mouse.
The optional parameter allows you to specify a reference rectangle and a pivot rectangle for the expansion. If not provided, the function uses the current selection state to determine how to expand downward.
cellSelectionExpandUp
Expands the current cell selection upward from a reference point. This function is typically used during interactive selection operations, such as when a user is extending a selection with the keyboard or mouse.
The optional parameter allows you to specify a reference rectangle and a pivot rectangle for the expansion. If not provided, the function uses the current selection state to determine how to expand upward.
cellSelectionExpandStart
Expands the current cell selection toward the start (left in LTR layouts) from a reference point. This function is typically used during interactive selection operations, such as when a user is extending a selection with the keyboard or mouse.
The optional parameter allows you to specify a reference rectangle and a pivot rectangle for the expansion. If not provided, the function uses the current selection state to determine how to expand toward the start.
cellSelectionExpandEnd
Expands the current cell selection toward the end (right in LTR layouts) from a reference point. This function is typically used during interactive selection operations, such as when a user is extending a selection with the keyboard or mouse.
The optional parameter allows you to specify a reference rectangle and a pivot rectangle for the expansion. If not provided, the function uses the current selection state to determine how to expand toward the end.
cellSelectionDeselectRect
Deselects all cells within the specified rectangular area. This function accepts
a CellSelectionRect
object that defines the boundaries of the area to deselect.
Any cells that fall within this rectangle will be removed from the current selection.
cellSelectionSelectRect
Selects all cells within the specified rectangular area. This function accepts
a CellSelectionRect
object that defines the boundaries of the area to
select, and an optional additive
boolean parameter that determines whether
to add to the existing selection or replace it.
When additive
is true
, the specified rectangle will be added
to the current selection. When additive
is false
or omitted, the
current selection will be cleared before selecting the new rectangle.
columnPivotsLoading
Returns a boolean indicating whether pivot operations are currently in progress. This function is useful for displaying loading indicators or disabling pivot-related UI elements while pivot operations are being processed.
columnPivotsReload
Forces a reload of the pivot data and recalculation of pivot tables. This method is useful when the underlying data has changed or when pivot configuration has been modified, and you need to update the pivot view to reflect these changes.
columnPivotFilterModel
Returns the current filter model applied to pivot operations. The filter model defines the criteria used to filter data before pivot calculations are performed. This is useful for understanding or saving the current state of pivot filters.
columnPivotSortModel
Returns the current sort model applied to pivot operations. The sort model defines how pivot data is sorted, which affects the ordering of rows and columns in the pivot table. This is useful for understanding or saving the current state of pivot sorting.
columnPivotSetSortModel
Sets a new sort model for pivot operations. This method allows you to change how pivot data is sorted, affecting the ordering of rows and columns in the pivot table. The sort model consists of an array of sort items, each specifying a column ID and sort direction.
columnPivotSetFilterModel
Sets a new filter model for pivot operations. This method allows you to change the criteria used to filter data before pivot calculations are performed. The filter model defines which records are included in the pivot table based on specific conditions.
columnPivotField
Extracts a field value from a row node for a specific pivot column. This method is used internally during pivot operations to access the data needed for pivot calculations. It handles the complexity of pivot data structures and provides access to the appropriate value.
columnPivotFieldFromData
Extracts a field value directly from a data object for a specific pivot column.
Unlike columnPivotField
, this method works with raw data objects rather
than row nodes. It's useful when you need to access
pivot-related values outside the context of the grid's row structure.
columnPivotMeasureField
Extracts a measure field value from a data object for a specific measure column in a pivot table. Measure fields are the values that get aggregated (summed, averaged, etc.) in pivot tables. This method provides access to these values for custom calculations or display purposes.
columnPivots
Returns an array of all columns that are currently being used as pivot columns. This includes columns used for row grouping, column grouping, and values in the pivot table. This method is useful for understanding the current pivot configuration.
columnIsPivot
Checks if a specific column is currently being used as a pivot column. Returns a boolean indicating whether the column is part of the pivot configuration. This is useful for conditionally applying styles or behaviors to pivot columns.
The types for clipboard operations are:
export interface ClipboardTransformCopyParams {
readonly api: API;
readonly data: unknown[][];
readonly rect: CellSelectionRect;
}
export interface ClipboardTransformPasteParams {
readonly api: API;
readonly clipboard: ClipboardItems;
readonly rect: CellSelectionRect;
}
export interface ClipboardTransformCellValueParams {
readonly api: API;
readonly column: Column;
readonly row: RowNode<D>;
readonly field: unknown;
}
export interface ClipboardTransformHeaderParams {
readonly api: API;
readonly column: Column;
readonly header: string;
}
export interface ClipboardTransformHeaderGroupParams {
readonly api: API;
readonly groupPath: string[];
readonly group: string;
readonly columnsInGroup: Column[];
}
export type ClipboardTransformCellValue = (
p: ClipboardTransformCellValueParams
) => string;
export type ClipboardTransformHeader = (
p: ClipboardTransformHeaderParams
) => string;
export type ClipboardTransformHeaderGroup = (
p: ClipboardTransformHeaderGroupParams
) => string;
export type ClipboardTransformCopy = (
p: ClipboardTransformCopyParams
) => ClipboardItems;
export type ClipboardTransformPaste = (
p: ClipboardTransformPasteParams
) => unknown[][] | Promise<unknown[][]>;
export type ClipboardCopyOptions = {
readonly includeHeaders?: boolean;
readonly includeHeaderGroups?: boolean;
readonly uniformHeaderGroupCopy?: boolean;
readonly transformCellValue?: ClipboardTransformCellValue;
readonly transformHeader?: ClipboardTransformHeader;
readonly transformHeaderGroup?: ClipboardTransformHeaderGroup;
readonly transformCopy?: ClipboardTransformCopy;
};
export type ClipboardPasteOptions = {
readonly transformPaste?: ClipboardTransformPaste;
};
clipboardCopyCells
Copies the content of selected cells to the system clipboard. If no rectangle is specified, the current selection is used. This method allows for customization of the copy operation through various options.
The options parameter enables you to:
This method returns a Promise that resolves when the copy operation is complete. The copied data is placed on the system clipboard in a format suitable for pasting into spreadsheet applications or other grid components.
clipboardCutCells
Cuts the content of selected cells to the system clipboard and clears their values in the grid. If no rectangle is specified, the current selection is used. This method allows for customization of the cut operation through various options.
The options parameter is identical to the one used in clipboardCopyCells
, enabling you to:
This method returns a Promise that resolves when the cut operation is complete. The cut data is placed on the system clipboard, and the corresponding cells in the grid are cleared according to the grid's editing rules.
clipboardPasteCells
Pastes content from the system clipboard into the grid at the position of the current selection or a specified rectangle. This method allows for customization of the paste operation through options.
The rect
parameter determines where the paste operation begins. If not provided,
the current selection or active cell is used as the starting point.
The paste operation will extend from this starting point based on the dimensions of the data being pasted.
The options parameter allows you to provide a transform function that can modify the clipboard data before it's applied to the grid. This is useful for format conversion, validation, or other custom processing of pasted data.
This method returns a Promise that resolves when the paste operation is complete. The cells in the grid are updated with the pasted values according to the grid's editing rules and any transformations applied.
columnMenuOpen
Opens the column menu for a specified column. The menu is positioned relative to the target element provided. This function is typically used to display column-specific operations such as sorting, filtering, or customization options.
The Target
parameter defines the positioning anchor for the menu,
which can be either a DOM element or coordinates.
columnMenuClose
Closes any currently open column menu. This function can be called to programmatically dismiss the column menu without user interaction, which is useful when implementing custom UI behaviors or responding to specific events.
contextMenuClose
Closes any currently open context menu. This function can be called to programmatically dismiss the context menu without user interaction, which is useful when implementing custom UI behaviors or responding to specific events.
panelFrameOpen
Opens a panel frame with the specified ID. Panel frames are typically used for displaying persistent UI elements such as sidebars, inspectors, or configuration panels.
The optional context
parameter allows you to pass data to the panel component,
which can be used to initialize or configure the panel content based on the current state or selection.
panelFrameClose
Closes any currently open panel frame. This function can be called to programmatically dismiss the panel without user interaction, which is useful when implementing workflows that require dynamic UI changes or responding to specific events.
dialogFrameOpen
Opens a dialog frame with the specified ID. Dialog frames are typically used for modal interactions that require user input or acknowledgment before proceeding, such as confirmation prompts, settings forms, or detail views.
The optional context
parameter allows you to pass data to the dialog component,
which can be used to initialize or configure the dialog content based on the current state or selection.
dialogFrameClose
Closes any currently open dialog frame. This function can be called to programmatically dismiss the dialog without user interaction, which is useful when implementing workflows that need to close dialogs based on programmatic conditions rather than explicit user actions.
popoverFrameOpen
Opens a popover frame with the specified ID. The popover is positioned relative to the target element provided. Popovers are typically used for contextual information or actions that are related to a specific element in the UI.
The Target
parameter defines the positioning anchor for the popover, which can be either a
DOM element or coordinates. The optional context
parameter allows you to pass
data to the popover component.
popoverFrameClose
Closes any currently open popover frame. This function can be called to programmatically dismiss the popover without user interaction, which is useful when implementing custom UI behaviors or responding to specific events.
menuFrameOpen
Opens a menu frame with the specified ID. The menu is positioned relative to the target element provided. Menu frames are typically used for displaying context-specific options or actions, similar to dropdown menus or context menus.
The Target
parameter defines the positioning anchor for the menu, which can be
either a DOM element or coordinates. The optional context
parameter allows you
to pass data to the menu component.
menuFrameClose
Closes any currently open menu frame. This function can be called to programmatically dismiss the menu without user interaction, which is useful when implementing custom UI behaviors or responding to specific events.