Skip to content

Commit

Permalink
WIP - fix(core): don't override alwaysShowVerticalScroll flag
Browse files Browse the repository at this point in the history
- the `alwaysShowVerticalScroll` flag should be dealt directly in the core and it should never show vertical scroll on left frozen container, even when the `alwaysShowVerticalScroll` is set to True (see core lib [PR #537](6pac/SlickGrid#537))
- requires core lib [PR #537](6pac/SlickGrid#537) to be merged and released
  • Loading branch information
Ghislain Beaulac authored and Ghislain Beaulac committed Oct 7, 2020
1 parent bd24727 commit 48f8eeb
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/app/examples/grid-colspan.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export class GridColspanComponent implements OnInit {
];

this.gridOptions2 = {
alwaysShowVerticalScroll: false, // disable scroll since we don't want it to show on the left pinned columns
enableCellNavigation: true,
enableColumnReorder: false,
createPreHeaderPanel: true,
Expand Down Expand Up @@ -112,7 +111,7 @@ export class GridColspanComponent implements OnInit {
}

setFrozenColumns2(frozenCols: number) {
this.gridObj2.setOptions({ frozenColumn: frozenCols, alwaysShowVerticalScroll: false });
this.gridObj2.setOptions({ frozenColumn: frozenCols });
this.gridOptions2 = this.gridObj2.getOptions();
}

Expand Down
3 changes: 1 addition & 2 deletions src/app/examples/grid-frozen.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ export class GridFrozenComponent implements OnInit {
containerId: 'demo-container',
sidePadding: 10
},
alwaysShowVerticalScroll: false, // disable scroll since we don't want it to show on the left pinned columns
enableExcelCopyBuffer: true,
enableCellNavigation: true,
editable: true,
Expand Down Expand Up @@ -276,7 +275,7 @@ export class GridFrozenComponent implements OnInit {
}

setFrozenColumns(frozenCols: number) {
this.gridObj.setOptions({ frozenColumn: frozenCols, alwaysShowVerticalScroll: false });
this.gridObj.setOptions({ frozenColumn: frozenCols });
this.gridOptions = this.gridObj.getOptions();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ describe('gridMenuExtension', () => {

expect(onCommandSpy).toHaveBeenCalled();
expect(setColumnsSpy).toHaveBeenCalled();
expect(setOptionsSpy).toHaveBeenCalledWith({ frozenColumn: -1, alwaysShowVerticalScroll: true });
expect(setOptionsSpy).toHaveBeenCalledWith({ frozenColumn: -1 });
});

it('should call "clearFilters" and dataview refresh when the command triggered is "clear-filter"', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ describe('headerMenuExtension', () => {
instance.onCommand.notify({ column: columnsMock[0], grid: gridStub, command: 'freeze-columns' }, new Slick.EventData(), gridStub);

expect(onCommandSpy).toHaveBeenCalled();
expect(setOptionsSpy).toHaveBeenCalledWith({ frozenColumn: 0, alwaysShowVerticalScroll: false });
expect(setOptionsSpy).toHaveBeenCalledWith({ frozenColumn: 0 });
expect(setColumnsSpy).toHaveBeenCalled();
});

Expand All @@ -429,7 +429,7 @@ describe('headerMenuExtension', () => {
instance.onCommand.notify({ column: columnsMock[1], grid: gridStub, command: 'freeze-columns' }, new Slick.EventData(), gridStub);

expect(onCommandSpy).toHaveBeenCalled();
expect(setOptionsSpy).toHaveBeenCalledWith({ frozenColumn: -1, alwaysShowVerticalScroll: false });
expect(setOptionsSpy).toHaveBeenCalledWith({ frozenColumn: -1 });
expect(setColumnsSpy).toHaveBeenCalled();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,7 @@ export class GridMenuExtension implements Extension {
switch (args.command) {
case 'clear-frozen-columns':
const visibleColumns = [...this.sharedService.visibleColumns];
const showVerticalScroll = this.sharedService.gridOptions && this.sharedService.gridOptions.enableGridMenu || false;
this.sharedService.grid.setOptions({ frozenColumn: -1, alwaysShowVerticalScroll: showVerticalScroll });
this.sharedService.grid.setOptions({ frozenColumn: -1 });
if (Array.isArray(visibleColumns) && Array.isArray(this.sharedService.allColumns) && visibleColumns.length !== this.sharedService.allColumns.length) {
this.sharedService.grid.setColumns(visibleColumns);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export class HeaderMenuExtension implements Extension {
case 'freeze-columns':
const visibleColumns = [...this.sharedService.visibleColumns];
const columnPosition = visibleColumns.findIndex((col) => col.id === args.column.id);
this.sharedService.grid.setOptions({ frozenColumn: columnPosition, alwaysShowVerticalScroll: false });
this.sharedService.grid.setOptions({ frozenColumn: columnPosition } as GridOption);

// to freeze columns, we need to take only the visible columns and we also need to use setColumns() when some of them are hidden
// to make sure that we only use the visible columns, not doing this would show back some of the hidden columns
Expand Down

0 comments on commit 48f8eeb

Please sign in to comment.