Skip to content

Commit d4f1ba5

Browse files
fix: tree grouping breaks if rows are assigned statically (#77)
Fixes the issue where tree grouping breaks if rows are directly set on ngx-datatable without doing any async calls.
1 parent f3131cb commit d4f1ba5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

projects/ngx-datatable/src/lib/components/datatable.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,14 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit, After
12811281
// if there are no sort criteria we reset the rows with original rows
12821282
if (!this.sorts || !this.sorts?.length) {
12831283
this._internalRows = this._rows;
1284+
// if there is any tree relation then re-group rows accordingly
1285+
if (this.treeFromRelation && this.treeToRelation) {
1286+
this._internalRows = groupRowsByParents(
1287+
this._internalRows,
1288+
optionalGetterForProp(this.treeFromRelation),
1289+
optionalGetterForProp(this.treeToRelation)
1290+
);
1291+
}
12841292
}
12851293
if (this.groupedRows && this.groupedRows.length) {
12861294
const sortOnGroupHeader = this.sorts?.find(sortColumns => sortColumns.prop === this._groupRowsBy);

0 commit comments

Comments
 (0)