@progress/kendo-react-grid
Version:
React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package
252 lines (251 loc) • 7.66 kB
TypeScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2026 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import { CompositeFilterDescriptor, GroupDescriptor, SortDescriptor } from '@progress/kendo-data-query';
import { GridColumnState } from '../../../interfaces/GridColumnState.js';
import { CompositeHighlightDescriptor } from '../../../interfaces/CompositeHighlightDescriptor.js';
/**
* Represents the grid context type with all available grid operations and state.
*
* @hidden
*/
export interface SmartBoxGridContextType {
/**
* The current sort descriptors applied to the grid.
* Array of sort objects defining field and direction.
*/
sort?: SortDescriptor[];
/**
* The current filter descriptor applied to the grid.
* Composite filter defining logic and filter array.
*/
filter?: CompositeFilterDescriptor;
/**
* The current group descriptors applied to the grid.
* Array of group objects defining field and aggregates.
*/
group?: GroupDescriptor[];
/**
* The current highlight descriptor applied to the grid.
* Used to highlight specific cells or rows based on filter conditions.
*/
highlight?: CompositeHighlightDescriptor;
/**
* The current selection descriptor applied to the grid.
* Used to select specific cells or rows based on filter conditions.
*/
select?: CompositeHighlightDescriptor;
/**
* The current columns state (visibility, order, width, lock status).
* Array of column state objects defining the column configuration.
*/
columnsState?: GridColumnState[];
/**
* The current skip value for paging.
* Zero-based index for the first item to display.
*/
skip?: number;
/**
* The current take value for paging.
* Number of items to display per page.
*/
take?: number;
/**
* Reference to the visible grid columns.
*/
columnsRef?: any[];
/**
* Reference to the hidden grid columns.
*/
hiddenColumnsRef?: any[];
/**
* The data item key field name.
*/
dataItemKey?: string;
/**
* Gets the total number of data items.
*/
getTotal: () => number;
/**
* Gets the leaf data items (after grouping).
*/
getLeafDataItems: () => any[];
/**
* Exports the grid as PDF.
*/
exportAsPdf: () => void;
/**
* Handles sort changes.
*
* @param sort - The new sort descriptors to apply.
* @param event - The triggering event.
*/
sortChange: (sort: SortDescriptor[], event: any) => void;
/**
* Handles filter changes.
*
* @param filter - The new filter descriptor to apply, or undefined to clear filters.
* @param event - The triggering event.
*/
filterChange: (filter: CompositeFilterDescriptor | undefined, event: any) => void;
/**
* Handles group changes.
*
* @param group - The new group descriptors to apply.
* @param event - The triggering event.
*/
groupChange: (group: GroupDescriptor[], event: any) => void;
/**
* Applies highlight descriptor to the grid.
*
* @param highlight - The highlight descriptor to apply.
*/
applyHighlightDescriptor: (highlight: CompositeHighlightDescriptor) => void;
/**
* Applies selection descriptor to the grid.
*
* @param select - The selection descriptor to apply.
*/
applySelectionDescriptor: (select: CompositeHighlightDescriptor) => void;
/**
* Handles columns state changes.
*
* @param columnsState - The new columns state to apply.
*/
onColumnsStateChange: (columnsState: GridColumnState[]) => void;
/**
* Handles pager page changes.
*
* @param event - The page change event containing skip and take values.
*/
pagerPageChange: (event: {
skip: number;
take: number;
syntheticEvent: any;
}) => void;
}
/**
* Represents the grid state snapshot.
* This interface contains all the stateful properties that can be modified through AI commands.
*
* @hidden
*/
export interface SmartBoxGridState {
/**
* The current sort descriptors applied to the grid.
* Array of sort objects defining field and direction.
*/
sort?: SortDescriptor[];
/**
* The current filter descriptor applied to the grid.
* Composite filter defining logic and filter array.
*/
filter?: CompositeFilterDescriptor;
/**
* The current group descriptors applied to the grid.
* Array of group objects defining field and aggregates.
*/
group?: GroupDescriptor[];
/**
* The current highlight descriptor applied to the grid.
* Used to highlight specific cells or rows based on filter conditions.
*/
highlight?: CompositeHighlightDescriptor;
/**
* The current selection descriptor applied to the grid.
* Used to select specific cells or rows based on filter conditions.
*/
select?: CompositeHighlightDescriptor;
/**
* The current columns state (visibility, order, width, lock status).
* Array of column state objects defining the column configuration.
*/
columnsState?: GridColumnState[];
/**
* The current skip value for paging.
* Zero-based index for the first item to display.
*/
skip?: number;
/**
* The current take value for paging.
* Number of items to display per page.
*/
take?: number;
}
/**
* Represents a reference to the grid with essential methods.
*
* @hidden
*/
export interface SmartBoxGridRef {
/**
* Gets the total number of data items.
*/
getTotal: () => number;
/**
* Gets the leaf data items (after grouping).
*/
getLeafDataItems: () => any[];
/**
* Exports the grid as PDF.
*/
exportAsPdf: () => void;
/**
* The grid props.
*/
props: {
/**
* The data item key field name.
*/
dataItemKey?: string;
};
}
/**
* Represents the return value of the useSmartBoxGridState hook.
*
* @hidden
*/
export interface UseSmartBoxGridStateResult {
/**
* The grid columns with their field names, IDs, and possible values.
*/
columns: Array<{
id?: string;
field: string;
values?: any[];
}>;
/**
* The current grid state snapshot.
*/
gridState: SmartBoxGridState | undefined;
/**
* Reference to the grid with essential methods.
*/
gridRef: SmartBoxGridRef | null;
/**
* Function to handle grid state changes from AI responses.
*
* @param newState - The new partial state to apply.
*/
handleStateChange: (newState: Partial<SmartBoxGridState>) => void;
/**
* Function to export the grid as PDF.
*/
exportAsPdf: () => void;
}
/**
* Hook to manage grid state for SmartBox AI assistant operations.
*
* This hook extracts the current grid state from the grid context and provides
* functions to update the grid state based on AI responses.
*
* @param gridContext - The grid context providing access to grid operations.
* @returns An object containing grid state and management functions.
*
* @hidden
*/
export declare function useSmartBoxGridState(gridContext: SmartBoxGridContextType | null): UseSmartBoxGridStateResult;