From 8f41098f8c2a081e34ce8ddc62f64fa2ccccd9ae Mon Sep 17 00:00:00 2001 From: Ondrej Skotnica Date: Tue, 30 Jan 2024 14:31:24 +0100 Subject: [PATCH 1/3] Table | Expandable rows broken with paginator #13783 --- src/app/components/table/table.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/components/table/table.ts b/src/app/components/table/table.ts index a62e121015a..3071cda3779 100644 --- a/src/app/components/table/table.ts +++ b/src/app/components/table/table.ts @@ -3168,7 +3168,7 @@ export class TableBody implements AfterViewInit, OnDestroy { shouldRenderRowGroupHeader(value: any, rowData: any, i: number) { let currentRowFieldData = ObjectUtils.resolveFieldData(rowData, this.dt.groupRowsBy); - let prevRowData = value[i - 1]; + let prevRowData = value[i - (1 + this.dt._first)]; if (prevRowData) { let previousRowFieldData = ObjectUtils.resolveFieldData(prevRowData, this.dt.groupRowsBy); return currentRowFieldData !== previousRowFieldData; @@ -3179,7 +3179,7 @@ export class TableBody implements AfterViewInit, OnDestroy { shouldRenderRowGroupFooter(value: any, rowData: any, i: number) { let currentRowFieldData = ObjectUtils.resolveFieldData(rowData, this.dt.groupRowsBy); - let nextRowData = value[i + 1]; + let nextRowData = value[i - (1 + this.dt._first)]; if (nextRowData) { let nextRowFieldData = ObjectUtils.resolveFieldData(nextRowData, this.dt.groupRowsBy); return currentRowFieldData !== nextRowFieldData; From 13cf724095cec2b1d9719acf2367b774a4d87667 Mon Sep 17 00:00:00 2001 From: Ondrej Skotnica Date: Tue, 30 Jan 2024 14:32:16 +0100 Subject: [PATCH 2/3] Table | Row Expansion and Selection not Working Together #14081 --- src/app/components/table/table.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/components/table/table.ts b/src/app/components/table/table.ts index 3071cda3779..04c2e982142 100644 --- a/src/app/components/table/table.ts +++ b/src/app/components/table/table.ts @@ -2426,11 +2426,13 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable } toggleRow(rowData: any, event?: Event) { - if (!this.dataKey) { - throw new Error('dataKey must be defined to use row expansion'); + if (!this.dataKey && !this.groupRowsBy) { + throw new Error('dataKey or groupRowsBy must be defined to use row expansion'); } - let dataKeyValue = String(ObjectUtils.resolveFieldData(rowData, this.dataKey)); + let dataKeyValue = this.groupRowsBy ? + String(ObjectUtils.resolveFieldData(rowData, this.groupRowsBy)) : + String(ObjectUtils.resolveFieldData(rowData, this.dataKey)); if (this.expandedRowKeys[dataKeyValue] != null) { delete this.expandedRowKeys[dataKeyValue]; @@ -2460,7 +2462,9 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable } isRowExpanded(rowData: any): boolean { - return this.expandedRowKeys[String(ObjectUtils.resolveFieldData(rowData, this.dataKey))] === true; + return this.groupRowsBy ? + this.expandedRowKeys[String(ObjectUtils.resolveFieldData(rowData, this.groupRowsBy))] === true : + this.expandedRowKeys[String(ObjectUtils.resolveFieldData(rowData, this.dataKey))] === true; } isRowEditing(rowData: any): boolean { From c4411421db9a24083a77be216bb1eeb822a616d6 Mon Sep 17 00:00:00 2001 From: Ondrej Skotnica Date: Thu, 1 Feb 2024 10:42:46 +0100 Subject: [PATCH 3/3] Table | Expandable rows broken with paginator #13783 --- src/app/components/table/table.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/table/table.ts b/src/app/components/table/table.ts index 04c2e982142..9e186a1c4c0 100644 --- a/src/app/components/table/table.ts +++ b/src/app/components/table/table.ts @@ -3183,7 +3183,7 @@ export class TableBody implements AfterViewInit, OnDestroy { shouldRenderRowGroupFooter(value: any, rowData: any, i: number) { let currentRowFieldData = ObjectUtils.resolveFieldData(rowData, this.dt.groupRowsBy); - let nextRowData = value[i - (1 + this.dt._first)]; + let nextRowData = value[i + (1 + this.dt._first)]; if (nextRowData) { let nextRowFieldData = ObjectUtils.resolveFieldData(nextRowData, this.dt.groupRowsBy); return currentRowFieldData !== nextRowFieldData;