Skip to content

Commit a74a3d8

Browse files
committed
Table: improve tile mode
There may not always be a tile for a row. Therefore, implement Table.createTiles more lenient in order to avoid null pointer exceptions. In addition, the TableTileGridMediator ensures that null values removed from its list of tiles. The list of tiles of the TableTileGridMediator needs to be unique as the tiles will be rendered one after another. If there are duplicates in the list of tiles an 'Already rendered'-error will be thrown if the second occurrence is rendered. Therefore, the TableTileGridMediator removes all duplicates from its list of tiles. 379008
1 parent c27b01c commit a74a3d8

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎eclipse-scout-core/src/table/Table.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5209,8 +5209,10 @@ export class Table extends Widget implements TableModel, Filterable<TableRow> {
52095209
createTiles(rows: TableRow[]): Tile[] {
52105210
return rows.map(row => {
52115211
let tile = this.createTileForRow(row);
5212-
this._adaptTile(tile);
5213-
tile.rowId = row.id;
5212+
if (tile) {
5213+
this._adaptTile(tile);
5214+
tile.rowId = row.id;
5215+
}
52145216
return tile;
52155217
});
52165218
}

‎eclipse-scout-core/src/table/TableTileGridMediator.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ export class TableTileGridMediator extends Widget implements TableTileGridMediat
190190
}
191191

192192
setTiles(tiles: ObjectOrChildModel<Tile>[]) {
193+
tiles = arrays.ensure(tiles)
194+
.filter((value, index, array) => value && array.indexOf(value) === index); // remove duplicates
193195
this.setProperty('tiles', tiles);
194196
}
195197

@@ -435,7 +437,7 @@ export class TableTileGridMediator extends Widget implements TableTileGridMediat
435437
this.table.loadingSupport.renderLoading(true);
436438
}
437439

438-
override destroy() {
440+
protected override _destroy() {
439441
// destroy tiles manually since owner is the mediator thus the tileGrid can't destroy them
440442
this.tiles.forEach(tile => tile.destroy());
441443
this.tileAccordion.destroy();
@@ -528,7 +530,8 @@ export class TableTileGridMediator extends Widget implements TableTileGridMediat
528530
if (!this.table.tileMode || $.isEmptyObject(this.tilesMap)) {
529531
return;
530532
}
531-
this.tiles = this.table.rows.map(row => this.tilesMap[row.id]);
533+
this.tiles = this.table.rows.map(row => this.tilesMap[row.id])
534+
.filter((value, index, array) => value && array.indexOf(value) === index); // remove duplicates
532535
this.tileAccordion.setTiles(this.tiles);
533536
}
534537

0 commit comments

Comments
 (0)