Skip to content

Commit

Permalink
Table | Row Expansion and Selection not Working Together primefaces#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondrej Skotnica committed Jan 30, 2024
1 parent 8f41098 commit 13cf724
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/app/components/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 13cf724

Please sign in to comment.