AAE-13310: update and preserve column width preferences only on visible columns (#8488)

* AAE-13310: update and preserve column width preferences only on visible columns

* AAE-13310: Fixing lint issues
This commit is contained in:
Ehsan Rezaei
2023-04-20 09:43:19 +02:00
committed by GitHub
parent 98c0a3c7be
commit ee3f1cdf55
6 changed files with 139 additions and 8 deletions

View File

@@ -1968,6 +1968,38 @@ describe('Column Resizing', () => {
expect(adapter.setColumns).toHaveBeenCalledWith(columns);
}));
it('should set column widths while resizing ONLY on visible columns', fakeAsync(() => {
const adapter = dataTable.data;
spyOn(adapter, 'getColumns').and.returnValue([
{
key: 'name',
type: 'text',
width: 110,
isHidden: true
},
{
key: 'status',
type: 'text',
width: 120,
isHidden: false
},
{
key: 'created',
type: 'text',
width: 150
}
]);
spyOn(adapter, 'setColumns').and.callThrough();
dataTable.onResizing({ rectangle: { top: 0, bottom: 10, left: 0, right: 20, width: 65 } }, 0);
tick();
expect(adapter.setColumns).toHaveBeenCalledWith([
{ key: 'status', type: 'text', width: 65, isHidden: false },
{ key: 'created', type: 'text', width: 150 }
]);
}));
it('should set the column header style on resizing', fakeAsync(() => {
dataTable.onResizing({ rectangle: { top: 0, bottom: 10, left: 0, right: 20, width: 125 } }, 0);
tick();

View File

@@ -950,7 +950,7 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
onResizing({ rectangle: { width } }: ResizeEvent, colIndex: number): void {
const timeoutId = setTimeout(() => {
const allColumns = this.data.getColumns();
const allColumns = this.data.getColumns().filter(column => !column.isHidden);
allColumns[colIndex].width = width;
this.data.setColumns(allColumns);