From 4728f6a9e3fc0036437ef25ec778e893887f0f18 Mon Sep 17 00:00:00 2001 From: Ghislain Beaulac Date: Fri, 12 Jun 2020 12:29:36 -0400 Subject: [PATCH 1/3] feat(pinning): add "Frozen Columns" to header menu - this feature will basically allow the user to freeze all columns until the current position of the column header he opened. For example if user is opening column 4 header menu and click on "Frozen Columns", it will freeze all 4 columns on the left. --- src/app/examples/grid-colspan.component.html | 11 +- src/app/examples/grid-colspan.component.ts | 21 ++- src/app/examples/grid-frozen.component.html | 10 ++ src/app/examples/grid-frozen.component.ts | 32 +++-- .../modules/angular-slickgrid/constants.ts | 2 + .../__tests__/gridMenuExtension.spec.ts | 54 ++++++-- .../__tests__/headerMenuExtension.spec.ts | 66 ++++++++- .../extensions/columnPickerExtension.ts | 2 +- .../extensions/gridMenuExtension.ts | 23 ++++ .../extensions/headerMenuExtension.ts | 31 +++++ .../angular-slickgrid/global-grid-options.ts | 4 + .../models/gridMenu.interface.ts | 7 +- .../models/headerMenu.interface.ts | 12 ++ .../models/locale.interface.ts | 12 +- .../models/slickGrid.interface.ts | 1 + .../groupingAndColspan.service.spec.ts | 18 +++ .../services/groupingAndColspan.service.ts | 9 +- .../styles/material-svg-icons.scss | 12 ++ src/assets/i18n/en.json | 2 + src/assets/i18n/fr.json | 2 + test/cypress/integration/example15.spec.js | 125 ++++++++++++++++++ test/cypress/integration/example20.spec.js | 103 +++++++++++++++ 22 files changed, 519 insertions(+), 40 deletions(-) create mode 100644 test/cypress/integration/example15.spec.js create mode 100644 test/cypress/integration/example20.spec.js diff --git a/src/app/examples/grid-colspan.component.html b/src/app/examples/grid-colspan.component.html index e57c4519d..47842fa49 100644 --- a/src/app/examples/grid-colspan.component.html +++ b/src/app/examples/grid-colspan.component.html @@ -14,11 +14,20 @@

Grid 1 (with Header Grouping & Colspan)


Grid 2 (with Header Grouping & Frozen/Pinned Columns)

+
+ + +
+ gridWidth="800" + (onAngularGridCreated)="angularGridReady2($event)"> diff --git a/src/app/examples/grid-colspan.component.ts b/src/app/examples/grid-colspan.component.ts index bc6c14203..99c594b25 100644 --- a/src/app/examples/grid-colspan.component.ts +++ b/src/app/examples/grid-colspan.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { Column, FieldType, GridOption } from './../modules/angular-slickgrid'; +import { Column, FieldType, GridOption, AngularGridInstance } from './../modules/angular-slickgrid'; @Component({ templateUrl: './grid-colspan.component.html', @@ -18,6 +18,8 @@ export class GridColspanComponent implements OnInit { `; + angularGrid2: AngularGridInstance; + gridObj2: any; columnDefinitions1: Column[]; columnDefinitions2: Column[]; gridOptions1: GridOption; @@ -30,6 +32,11 @@ export class GridColspanComponent implements OnInit { this.prepareGrid2(); } + angularGridReady2(angularGrid: AngularGridInstance) { + this.angularGrid2 = angularGrid; + this.gridObj2 = angularGrid.slickGrid; + } + prepareGrid1() { this.columnDefinitions1 = [ { id: 'title', name: 'Title', field: 'title', sortable: true, columnGroup: 'Common Factor' }, @@ -49,7 +56,7 @@ export class GridColspanComponent implements OnInit { showPreHeaderPanel: true, preHeaderPanelHeight: 28, explicitInitialization: true, - colspanCallback: this.renderDifferentColspan + colspanCallback: this.renderDifferentColspan, }; this.dataset1 = this.getData(500); @@ -57,6 +64,7 @@ export class GridColspanComponent implements OnInit { prepareGrid2() { this.columnDefinitions2 = [ + { id: 'sel', name: '#', field: 'num', behavior: 'select', cssClass: 'cell-selection', width: 40, resizable: false, selectable: false }, { id: 'title', name: 'Title', field: 'title', sortable: true, columnGroup: 'Common Factor' }, { id: 'duration', name: 'Duration', field: 'duration', columnGroup: 'Common Factor' }, { id: 'start', name: 'Start', field: 'start', columnGroup: 'Period' }, @@ -73,7 +81,9 @@ export class GridColspanComponent implements OnInit { showPreHeaderPanel: true, preHeaderPanelHeight: 25, explicitInitialization: true, - frozenColumn: 1, + frozenColumn: 2, + gridMenu: { hideClearFrozenColumnsCommand: false }, + headerMenu: { hideFreezeColumnsCommand: false } }; this.dataset2 = this.getData(500); @@ -97,6 +107,11 @@ export class GridColspanComponent implements OnInit { return mockDataset; } + setFrozenColumns2(frozenCols: number) { + this.gridObj2.setOptions({ frozenColumn: frozenCols, alwaysShowVerticalScroll: false }); + this.gridOptions2 = this.gridObj2.getOptions(); + } + /** * A callback to render different row column span * Your callback will always have the "item" argument which you can use to decide on the colspan diff --git a/src/app/examples/grid-frozen.component.html b/src/app/examples/grid-frozen.component.html index 83b8d3224..0c8bd8370 100644 --- a/src/app/examples/grid-frozen.component.html +++ b/src/app/examples/grid-frozen.component.html @@ -19,6 +19,16 @@

{{title}}

Set + + +
+ + +