Skip to content

Commit

Permalink
fix: tree grouping breaks if rows are assigned statically (#77)
Browse files Browse the repository at this point in the history
Fixes the issue where  tree grouping breaks if rows are directly set on ngx-datatable without doing any async calls.
  • Loading branch information
chintankavathia authored Jul 26, 2024
1 parent f3131cb commit d4f1ba5
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,14 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit, After
// if there are no sort criteria we reset the rows with original rows
if (!this.sorts || !this.sorts?.length) {
this._internalRows = this._rows;
// if there is any tree relation then re-group rows accordingly
if (this.treeFromRelation && this.treeToRelation) {
this._internalRows = groupRowsByParents(
this._internalRows,
optionalGetterForProp(this.treeFromRelation),
optionalGetterForProp(this.treeToRelation)
);
}
}
if (this.groupedRows && this.groupedRows.length) {
const sortOnGroupHeader = this.sorts?.find(sortColumns => sortColumns.prop === this._groupRowsBy);
Expand Down

0 comments on commit d4f1ba5

Please sign in to comment.