/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { SelectionAggregate, SelectionAggregates } from '../aggregates/aggregate-types'; import { ColumnComponent } from './../columns/column.component'; import { RowArgs } from './../rendering/common/row-args'; /** * Represents the callback used by the [`cellSelected`]({% slug api_grid_gridcomponent %}#toc-cellselected) property. ([See example](slug:grid_selection_custom#toc-setting-the-selected-cells)). * * @param row The row arguments. * @param column The column component. * @param colIndex The column index. * @returns An object with `selected` and `item` properties. */ export type CellSelectedFn = (row: RowArgs, column: ColumnComponent, colIndex: number) => { selected: boolean; item: CellSelectionItem; }; /** * Provides arguments for the Grid [`selectionChange`](slug:api_grid_gridcomponent#toc-selectionchange) event. */ export interface SelectionEvent { /** * Contains the cell selection aggregates. */ cellAggregates?: SelectionAggregates; /** * Lists the row items added to the selection. */ selectedRows?: RowArgs[]; /** * Lists the row items removed from the selection. */ deselectedRows?: RowArgs[]; /** * Lists the cell items added to the selection. */ selectedCells?: CellSelectionItem[]; /** * Lists the cell items removed from the selection. */ deselectedCells?: CellSelectionItem[]; /** * Shows the state of the `Ctrl` key (or the `Command` key on a Mac) during selection. */ ctrlKey?: boolean; /** * Shows the state of the `Shift` key during selection. */ shiftKey?: boolean; /** * Represents the initially clicked row in a `Shift`+click range row selection. */ rangeStartRow?: RowArgs; /** * Represents the item in a `Shift`+click range row selection. */ rangeEndRow?: RowArgs; /** * Represents the initially clicked cell in a `Shift`+click range cell selection. */ rangeStartCell?: CellSelectionItem; /** * Represents the cell in a `Shift`+click range cell selection. */ rangeEndCell?: CellSelectionItem; } /** * Configures the selection functionality of the Grid. ([See example]({% slug selection_grid %}#toc-setup)). * * @example * ```html * * * * * ``` */ export interface SelectableSettings { /** * Enables selection aggregates. By default, this property is set to `false`. * If you set `cellAggregates` to `true`, the Grid calculates all aggregate options. * Pass an array of [`SelectionAggregate`]({% slug api_grid_selectionaggregate %}) type options to choose which aggregates to calculate. * */ cellAggregates?: boolean | SelectionAggregate[]; /** * Enables selection. * */ enabled?: boolean; /** * Allows selection only through clicking a checkbox. * When enabled, clicking the row does not select it. * This applies if at least one checkbox column exists. * */ checkboxOnly?: boolean; /** * Sets the selectable mode. * */ mode?: SelectableMode; /** * Enables cell selection. * */ cell?: boolean; /** * Enables drag selection. * */ drag?: boolean; /** * Requires a meta key (`Ctrl` or `Command`) to select multiple items. By default, you must press a meta key to add a new row or cell to the selection. * */ metaKeyMultiSelect?: boolean; /** * Preserves the existing selection when you perform a new range selection. * */ multipleRanges?: boolean; } /** * Lists the available selection modes. [See example](slug:grid_row_selection). * * The available values are: * * `single`—Enables single selection. Clicking the selected row does not deselect it. [See example](slug:grid_row_selection#toc-single-row-selection). * * `multiple`—Enables multiple selection. [See example](slug:grid_row_selection#toc-multiple-rows-selection). * * @example * ```html * * ``` */ export type SelectableMode = "single" | "multiple"; /** * Lists the possible states of the select-all checkbox. * * @example * ```html * * * * * * ``` */ export type SelectAllCheckboxState = "checked" | "unchecked" | "indeterminate"; /** * Describes the Grid cell selection item type. */ export interface CellSelectionItem { /** * Identifies the selected item. */ itemKey?: any; /** * Identifies the selected item column. */ columnKey?: any; } /** * Lists the possible data types of the Grid selection items. * * @hidden */ export type GridSelectionItem = number | RowArgs | CellSelectionItem;