Skip to content

Commit

Permalink
refactor: use interface for row properties that may be set by the dat…
Browse files Browse the repository at this point in the history
…atable
  • Loading branch information
spike-rabbit committed Feb 27, 2025
1 parent a00d2f3 commit 9f9e752
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { BehaviorSubject } from 'rxjs';
import {
ActivateEvent,
CellContext,
Row,
RowOrGroup,
SortDirection,
SortPropDir,
Expand Down Expand Up @@ -99,9 +100,7 @@ import { AsyncPipe, NgTemplateOutlet } from '@angular/common';
standalone: true,
imports: [NgTemplateOutlet, DataTableGhostLoaderComponent, AsyncPipe]
})
export class DataTableBodyCellComponent<TRow extends { level?: number } = any>
implements DoCheck, OnDestroy
{
export class DataTableBodyCellComponent<TRow extends Row = any> implements DoCheck, OnDestroy {
private cd = inject(ChangeDetectorRef);

@Input() displayCheck: (row: RowOrGroup<TRow>, column: TableColumn, value: any) => boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
ActivateEvent,
DragEventData,
Group,
Row,
RowOrGroup,
ScrollEvent,
SelectionType,
Expand Down Expand Up @@ -263,9 +264,7 @@ import { ProgressBarComponent } from './progress-bar.component';
DraggableDirective
]
})
export class DataTableBodyComponent<TRow extends { treeStatus?: TreeStatus } = any>
implements OnInit, OnDestroy
{
export class DataTableBodyComponent<TRow extends Row = any> implements OnInit, OnDestroy {
cd = inject(ChangeDetectorRef);

@Input() rowDefTemplate?: TemplateRef<any>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
PageEvent,
PagerPageEvent,
ReorderEvent,
Row,
RowOrGroup,
ScrollEvent,
SelectionType,
Expand Down Expand Up @@ -96,7 +97,7 @@ import { ProgressBarComponent } from './body/progress-bar.component';
ProgressBarComponent
]
})
export class DatatableComponent<TRow = any>
export class DatatableComponent<TRow extends Row = any>
implements OnInit, DoCheck, AfterViewInit, AfterContentInit, OnDestroy
{
private scrollbarHelper = inject(ScrollbarHelper);
Expand Down
9 changes: 9 additions & 0 deletions projects/ngx-datatable/src/lib/types/public.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ export interface RowDetailContext<TRow = any> {
disableRow$?: Observable<boolean>;
}

/**
* Consumer provided rows should extend this interface
* to get access to implicit row properties which are set by the datatable if required.
*/
export interface Row {
treeStatus?: TreeStatus;
level?: number;
}

export interface ReorderEvent {
column: TableColumn;
prevValue: number;
Expand Down

0 comments on commit 9f9e752

Please sign in to comment.