diff --git a/projects/ngx-datatable/src/lib/components/body/body-row.directive.ts b/projects/ngx-datatable/src/lib/components/body/body-row.directive.ts new file mode 100644 index 000000000..a2150d011 --- /dev/null +++ b/projects/ngx-datatable/src/lib/components/body/body-row.directive.ts @@ -0,0 +1,18 @@ +import { Directive } from '@angular/core'; +import { Group, TreeStatus } from '../../types/public.types'; + +@Directive({ + selector: '[ngx-datatable-body-row]' +}) +export class DatatableBodyRowDirective { + static ngTemplateContextGuard( + directive: DatatableBodyRowDirective, + context: unknown + ): context is { + row: TRow; + groupValue: Group[]; + index: number; + } { + return true; + } +} diff --git a/projects/ngx-datatable/src/lib/components/body/body.component.ts b/projects/ngx-datatable/src/lib/components/body/body.component.ts index 80d0de676..bb1eb1d1c 100644 --- a/projects/ngx-datatable/src/lib/components/body/body.component.ts +++ b/projects/ngx-datatable/src/lib/components/body/body.component.ts @@ -105,6 +105,46 @@ import { [selected]="selected" (rowContextmenu)="rowContextmenu.emit($event)" > + + @let rowItem = groupRow ?? group; + + + + @if (rowDefTemplate) { - + } } - - @if (isRow(group)) { - - - } - - @if (isGroup(group)) { @for (row of group.value; track rowTrackingFn(i, row); let i = $index) { - - + } } diff --git a/projects/ngx-datatable/src/lib/ngx-datatable.module.ts b/projects/ngx-datatable/src/lib/ngx-datatable.module.ts index fc48e7476..1f4686262 100644 --- a/projects/ngx-datatable/src/lib/ngx-datatable.module.ts +++ b/projects/ngx-datatable/src/lib/ngx-datatable.module.ts @@ -39,6 +39,7 @@ import { DatatableRowDefDirective, DatatableRowDefInternalDirective } from './components/body/body-row-def.component'; +import { DatatableBodyRowDirective } from './components/body/body-row.directive'; @NgModule({ imports: [CommonModule], @@ -77,7 +78,8 @@ import { DisableRowDirective, DatatableRowDefComponent, DatatableRowDefDirective, - DatatableRowDefInternalDirective + DatatableRowDefInternalDirective, + DatatableBodyRowDirective ], exports: [ DatatableComponent, @@ -95,7 +97,8 @@ import { DatatableGroupHeaderTemplateDirective, DisableRowDirective, DatatableRowDefComponent, - DatatableRowDefDirective + DatatableRowDefDirective, + DatatableBodyRowDirective ] }) export class NgxDatatableModule {