Implement storing sorting and grouping for all tables (#20594)

This commit is contained in:
Bram Kragten
2024-04-24 11:06:00 +02:00
committed by GitHub
parent d9b71e754d
commit 62de16bb8e
12 changed files with 352 additions and 53 deletions

View File

@@ -529,11 +529,7 @@ export class HaDataTable extends LitElement {
}
if (this.appendRow || this.hasFab || this.groupColumn) {
const items = [...data];
if (this.appendRow) {
items.push({ append: true, content: this.appendRow });
}
let items = [...data];
if (this.groupColumn) {
const grouped = groupBy(items, (item) => item[this.groupColumn!]);
@@ -599,14 +595,18 @@ export class HaDataTable extends LitElement {
}
});
this._items = groupedItems;
} else {
this._items = items;
items = groupedItems;
}
if (this.appendRow) {
items.push({ append: true, content: this.appendRow });
}
if (this.hasFab) {
this._items = [...this._items, { empty: true }];
items.push({ empty: true });
}
this._items = items;
} else {
this._items = data;
}