[ADF-2765] Fix for the gallery view in datatable component (#3470)

* [ADF-2765] Fix for the gallery view in datatable component

* [ADF-2765] Fixed lint errors

* [ADF-2765] Changed maximum columns per row number

* [ADF-2765] Removed trailing whitespace
This commit is contained in:
davidcanonieto
2018-07-05 00:36:21 +02:00
committed by Eugenio Romano
parent 23403076a9
commit edf82d9c05
3 changed files with 34 additions and 7 deletions

View File

@@ -161,6 +161,9 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
isSelectAllChecked: boolean = false;
selection = new Array<DataRow>();
/** This array of fake rows fix the flex layout for the gallery view */
fakeRows = [];
private clickObserver: Observer<DataRowEvent>;
private click$: Observable<DataRowEvent>;
@@ -188,6 +191,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
})
);
}
this.datatableLayoutFix();
this.setTableSchema();
}
@@ -220,6 +224,10 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
if (this.isPropertyChanged(changes['sorting'])) {
this.setTableSorting(changes['sorting'].currentValue);
}
if (this.isPropertyChanged(changes['display'])) {
this.datatableLayoutFix();
}
}
ngDoCheck() {
@@ -654,4 +662,16 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
this.dataRowsChanged = null;
}
}
datatableLayoutFix() {
const maxGalleryRows = 25;
if (this.display === 'gallery') {
for (let i = 0; i < maxGalleryRows; i++) {
this.fakeRows.push('');
}
} else {
this.fakeRows = [];
}
}
}