Skip to content

Commit d759d9e

Browse files
ascabknightPranavSenthilnathan
authored andcommitted
[@types/react-data-grid] Adding missing types to support Tree Views (DefinitelyTyped#40279)
* Adding missing types to support trees for react-data-grid * Applying minor changes as suggested by SupernaviX
1 parent 5eeff62 commit d759d9e

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

types/react-data-grid/index.d.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ declare namespace AdazzleReactDataGrid {
6262
* @param e Information about the event
6363
*/
6464
onCellsDragged?: (e: CellDragEvent) => void
65+
/**
66+
* Invoked when the user clicks on one cell to expand it.
67+
* @param e Information about the event
68+
*/
69+
onCellExpand?: (e:CellExpandEvent<T>) => void
70+
71+
getSubRowDetails?: (row: T) => SubRowDetails
72+
6573
/**
6674
* Invoked when the user double clicks on the drag handle of an editable cell.
6775
* Should update the values of the cells beneath the selected cell.
@@ -456,6 +464,54 @@ declare namespace AdazzleReactDataGrid {
456464
value: any
457465
}
458466

467+
/**
468+
* Information about a cell expanded.
469+
*/
470+
interface CellExpandEvent<T = any> {
471+
/**
472+
* The row index where the cell is being expanded.
473+
*/
474+
rowIdx: number
475+
/**
476+
* The column index where the cell is being expanded.
477+
*/
478+
idx: number
479+
/**
480+
* The values of the row.
481+
*/
482+
rowData: T
483+
/**
484+
* Expand data.
485+
*/
486+
expandArgs: any
487+
}
488+
489+
/**
490+
* Information about subrows.
491+
*/
492+
interface SubRowDetails<T = any> {
493+
/**
494+
* Determines if the cell can expand.
495+
*/
496+
canExpand?: boolean;
497+
/**
498+
* Sets the field/column that will be use to expand the subrows.
499+
*/
500+
field: string;
501+
/**
502+
* Determines if the row has already expanded.
503+
*/
504+
expanded: boolean;
505+
/**
506+
* Children data.
507+
*/
508+
children?: T[];
509+
treeDepth?: number;
510+
siblingIndex?: number;
511+
numberSiblings?: number;
512+
group?: boolean;
513+
}
514+
459515
/**
460516
* Information about a drag handle double click. Generic event type returns untyped row, use parameterized type with the row type as the parameter
461517
* @default T = any
@@ -584,6 +640,7 @@ declare namespace AdazzleReactDataGrid {
584640
export import RowUpdateEvent = AdazzleReactDataGrid.RowUpdateEvent;
585641
export import SelectionParams = AdazzleReactDataGrid.SelectionParams;
586642
export import CellDragEvent = AdazzleReactDataGrid.CellDragEvent;
643+
export import CellExpandEvent = AdazzleReactDataGrid.CellExpandEvent;
587644
export import DragHandleDoubleClickEvent = AdazzleReactDataGrid.DragHandleDoubleClickEvent;
588645
export import CellCopyPasteEvent = AdazzleReactDataGrid.CellCopyPasteEvent;
589646
export import GridRowsUpdatedEvent = AdazzleReactDataGrid.GridRowsUpdatedEvent;

0 commit comments

Comments
 (0)