ag-grid-community
Version:
Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue
93 lines (92 loc) • 5.42 kB
TypeScript
import type { GridApi } from '../api/gridApi';
import type { ChangedRowNodes } from '../clientSideRowModel/changedRowNodes';
import type { NamedBean } from '../context/bean';
import type { GridOptions, SelectAllMode } from '../entities/gridOptions';
import { RowNode } from '../entities/rowNode';
import type { SelectionEventSourceType } from '../events';
import type { ISelectionService, ISetNodesSelectedParams } from '../interfaces/iSelectionService';
import type { ServerSideRowGroupSelectionState, ServerSideRowSelectionState } from '../interfaces/selectionState';
import type { ChangedPath } from '../utils/changedPath';
import { BaseSelectionService } from './baseSelectionService';
export declare class SelectionService extends BaseSelectionService implements NamedBean, ISelectionService {
beanName: "selectionSvc";
private readonly selectedNodes;
/** Only used to track detail grid selection state when master/detail is enabled */
private readonly detailSelection;
private groupSelectsDescendants;
private groupSelectsFiltered;
private mode?;
private masterSelectsDetail;
private csrm?;
private selectionBatchDepth;
private pendingSelectionChanged;
private pendingSelectionSource;
postConstruct(): void;
destroy(): void;
handleSelectionEvent(event: MouseEvent | KeyboardEvent, rowNode: RowNode, source: SelectionEventSourceType): number;
setNodesSelected({ newValue, clearSelection, suppressFinishActions, nodes, event, source, keepDescendants, }: ISetNodesSelectedParams & {
keepDescendants?: boolean;
}): number;
private selectRange;
private selectChildren;
getSelectedNodes(): RowNode[];
getSelectedRows(): any[];
getSelectionCount(): number;
/**
* Drops a node leaving the model (destroyed, removed or detached) from the selection. Event-free
* and allocation-free: only updates the map, so callers can call it inline as they tear nodes down.
* The single `selectionChanged` and group roll-up are emitted by `updateSelectableAfterGrouping`.
*/
removeFromSelection(node: RowNode, source: SelectionEventSourceType): void;
updateGroupsFromChildrenSelections(source: SelectionEventSourceType, changedPath?: ChangedPath, event?: Event): boolean;
private clearOtherNodes;
/** Selection-index chokepoint: mirrors the base's `__selected` flip into `selectedNodes`, so the map is
* a pure derived index. Groups under groupSelectsDescendants are computed, not stored. */
selectRowNode(rowNode: RowNode, newValue?: boolean, e?: Event, source?: SelectionEventSourceType): boolean;
syncInRowNode(rowNode: RowNode, oldNode?: RowNode): void;
createDaemonNode(rowNode: RowNode): RowNode | undefined;
reset(source: SelectionEventSourceType): void;
private resetNodes;
getBestCostNodeSelection(): RowNode[] | undefined;
isEmpty(): boolean;
deselectAllRowNodes({ source, selectAll }: {
source: SelectionEventSourceType;
selectAll?: SelectAllMode;
}): void;
getSelectAllState(selectAll?: SelectAllMode): boolean | null;
hasNodesToSelect(selectAll: SelectAllMode): boolean;
/**
* @param selectAll See `MultiRowSelectionOptions.selectAll`
* @returns all nodes including unselectable nodes which are the target of this selection attempt
*/
private getNodesToSelect;
private forEachNodeOnPage;
selectAllRowNodes(params: {
source: SelectionEventSourceType;
selectAll?: SelectAllMode;
}): void;
getSelectionState(): string[] | null;
setSelectionState(state: string[] | ServerSideRowSelectionState | ServerSideRowGroupSelectionState | undefined, source: SelectionEventSourceType, clearSelection?: boolean): void;
private canSelectAll;
/** Recomputes a node's selectable state. A row that turns non-selectable stays in the grid, so it is
* deselected eventfully (fires rowSelected for the visible row); the batch coalesces these. */
private recomputeSelectable;
/**
* Applies isRowSelectable to the affected nodes and deselects any that are no longer selectable. The
* callback runs once, on the fully-formed node. Scope: `changedPath` → changed subtree (hierarchical);
* `changedRowNodes` → added/updated rows only (flat); neither → all nodes (e.g. callback changed).
*/
protected updateSelectable(changedPath?: ChangedPath, changedRowNodes?: ChangedRowNodes): void;
/** Single post-refresh selectable pass, owned by the CSRM and run for both flat and hierarchical grids. */
updateSelectableAfterGrouping(changedPath: ChangedPath | undefined, changedRowNodes?: ChangedRowNodes): void;
refreshMasterNodeState(node: RowNode, e?: Event): void;
setDetailSelectionState(masterNode: RowNode, detailGridOptions: GridOptions, detailApi: GridApi): void;
private dispatchSelectionChanged;
/** Flushes a `selectionChanged` left pending by `removeFromSelection` when its refresh was deferred,
* so an unrelated later batch can't emit it with the wrong source. */
flushPendingSelectionChanged(): void;
/** Close the batch; the outermost close flushes the single coalesced `selectionChanged`. Callers MUST
* pair the opening `selectionBatchDepth++` with this in a `finally` so a throwing user callback can't
* leak the depth and freeze future events. */
private endSelectionBatch;
}