Skip to content

Commit

Permalink
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))
  • Loading branch information
Ghislain Beaulac authored and Ghislain Beaulac committed Oct 5, 2020
1 parent 4b99615 commit 094daad
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
17 changes: 8 additions & 9 deletions examples/webpack-demo-vanilla-bundle/src/examples/example04.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ExampleGridOptions } from './example-grid-options';
import './example02.scss';

// you can create custom validator to pass to an inline editor
const myCustomTitleValidator = (value, args) => {
const myCustomTitleValidator = (value, _args) => {
if (value === null || value === undefined || !value.length) {
return { valid: false, msg: 'This is a required field' };
} else if (!/^Task\s\d+$/.test(value)) {
Expand All @@ -36,7 +36,7 @@ interface ReportItem {
effortDriven: boolean;
}

const customEditableInputFormatter = (row: number, cell: number, value: any, columnDef: Column, item: ReportItem) => {
const customEditableInputFormatter = (_row: number, _cell: number, _value: any, _columnDef: Column, item: ReportItem) => {
return item.title;
};

Expand Down Expand Up @@ -282,7 +282,7 @@ export class Example4 {
{
command: 'command2', title: 'Command 2', positionOrder: 62,
// you can use the "action" callback and/or use "onCallback" callback from the grid options, they both have the same arguments
action: (e, args) => {
action: (_e, args) => {
console.log(args.dataContext, args.column);
// action callback.. do something
},
Expand Down Expand Up @@ -345,11 +345,10 @@ export class Example4 {
},
enableCheckboxSelector: true,
enableRowSelection: true,
alwaysShowVerticalScroll: false, // disable scroll since we don't want it to show on the left pinned columns
frozenColumn: this.frozenColumnCount,
frozenRow: this.frozenRowCount,
// frozenBottom: true, // if you want to freeze the bottom instead of the top, you can enable this property
editCommandHandler: (item, column, editCommand) => {
editCommandHandler: (_item, _column, editCommand) => {
this.commandQueue.push(editCommand);
editCommand.execute();
},
Expand All @@ -359,7 +358,7 @@ export class Example4 {
// all the Cell Menu callback methods (except the action callback)
// are available under the grid options as shown below
onCommand: (e, args) => this.executeCommand(e, args),
onOptionSelected: (e, args) => {
onOptionSelected: (_e, args) => {
// change "Completed" property with new option selected from the Cell Menu
const dataContext = args && args.dataContext;
if (dataContext && dataContext.hasOwnProperty('completed')) {
Expand Down Expand Up @@ -390,7 +389,7 @@ export class Example4 {
return this.dataset;
}

costDurationFormatter(row, cell, value, columnDef, dataContext) {
costDurationFormatter(_row, _cell, _value, _columnDef, dataContext) {
const costText = this.isNullUndefinedOrEmpty(dataContext.cost) ? 'n/a' : Slicker.Utilities.formatNumber(dataContext.cost, 0, 2, false, '$', '', '.', ',');
let durationText = 'n/a';
if (!this.isNullUndefinedOrEmpty(dataContext.duration) && dataContext.duration >= 0) {
Expand Down Expand Up @@ -454,8 +453,8 @@ export class Example4 {
}
}

executeCommand(e, args) {
const columnDef = args.column;
executeCommand(_e, args) {
// const columnDef = args.column;
const command = args.command;
const dataContext = args.dataContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,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 @@ -392,7 +392,7 @@ describe('headerMenuExtension', () => {
instance.onCommand.notify({ column: columnsMock[0], grid: gridStub, command: 'freeze-columns', item: { 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 @@ -405,7 +405,7 @@ describe('headerMenuExtension', () => {
instance.onCommand.notify({ column: columnsMock[1], grid: gridStub, command: 'freeze-columns', item: { 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
3 changes: 1 addition & 2 deletions packages/common/src/extensions/gridMenuExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,7 @@ export class GridMenuExtension implements Extension {
switch (args.command) {
case 'clear-frozen-columns':
const visibleColumns = [...this.sharedService.visibleColumns];
const showVerticalScroll = this.sharedService?.gridOptions?.enableGridMenu || false;
this.sharedService.slickGrid.setOptions({ frozenColumn: -1, alwaysShowVerticalScroll: showVerticalScroll });
this.sharedService.slickGrid.setOptions({ frozenColumn: -1 });
if (Array.isArray(visibleColumns) && Array.isArray(this.sharedService.allColumns) && visibleColumns.length !== this.sharedService.allColumns.length) {
this.sharedService.slickGrid.setColumns(visibleColumns);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/extensions/headerMenuExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,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.slickGrid.setOptions({ frozenColumn: columnPosition, alwaysShowVerticalScroll: false });
this.sharedService.slickGrid.setOptions({ frozenColumn: columnPosition });

// 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
Binary file not shown.

0 comments on commit 094daad

Please sign in to comment.