Skip to content

Commit 3561bfd

Browse files
committed
Merge branch 'pivot-grid-master' of https://github.com/IgniteUI/igniteui-angular into mdragnev/feat-10713
2 parents aca0f89 + abfea3e commit 3561bfd

29 files changed

+422
-107
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ All notable changes for each version of this project will be documented in this
2323
```
2424
- `IgxTabs` have full right-to-left (RTL) support.
2525

26+
- `IgxExcelExporterService`
27+
- Added support for exporting the grids' headers by default when the data is empty. This behavior can be controlled by the `alwaysExportHeaders` option of the IgxExcelExporterOptions object.
28+
2629
### General
2730

2831
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<ng-container *ngIf="!isHeader && !singleMode">
2-
<igx-checkbox [checked]="selected" [disableRipple]="true" [disableTransitions]="disableTransitions" [tabindex]="-1" (click)="disableCheck($event)" class="igx-combo__checkbox"></igx-checkbox>
2+
<!-- checkbox should not allow changing its state from UI click (that's why it should be readonly=true), becasue when cancelling the selectionChange event in the combo, then checkbox will still change state.-->
3+
<igx-checkbox [checked]="selected" [readonly]="true" [disableRipple]="true" [disableTransitions]="disableTransitions" [tabindex]="-1" (click)="disableCheck($event)" class="igx-combo__checkbox"></igx-checkbox>
34
</ng-container>
45
<span class="igx-drop-down__inner"><ng-content></ng-content></span>

projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const CSS_CLASS_INPUT_COSY = 'igx-input-group--cosy';
6565
const CSS_CLASS_INPUT_COMPACT = 'igx-input-group--compact';
6666
const CSS_CLASS_INPUT_COMFORTABLE = 'igx-input-group--comfortable';
6767
const CSS_CLASS_EMPTY = 'igx-combo__empty';
68+
const CSS_CLASS_ITEM_CHECKBOX = 'igx-combo__checkbox';
69+
const CSS_CLASS_ITME_CHECKBOX_CHECKED = 'igx-checkbox--checked';
6870
const defaultDropdownItemHeight = 40;
6971
const defaultDropdownItemMaxHeight = 400;
7072

@@ -1927,12 +1929,19 @@ describe('igxCombo', () => {
19271929
combo = fixture.componentInstance.combo;
19281930
input = fixture.debugElement.query(By.css(`.${CSS_CLASS_COMBO_INPUTGROUP}`));
19291931
});
1930-
const simulateComboItemCheckboxClick = (itemIndex: number, isHeader = false) => {
1932+
const simulateComboItemClick = (itemIndex: number, isHeader = false) => {
19311933
const itemClass = isHeader ? CSS_CLASS_HEADERITEM : CSS_CLASS_DROPDOWNLISTITEM;
19321934
const dropdownItem = fixture.debugElement.queryAll(By.css('.' + itemClass))[itemIndex];
19331935
dropdownItem.triggerEventHandler('click', UIInteractions.getMouseEvent('click'));
19341936
fixture.detectChanges();
19351937
};
1938+
const simulateComboItemCheckboxClick = (itemIndex: number, isHeader = false) => {
1939+
const itemClass = isHeader ? CSS_CLASS_HEADERITEM : CSS_CLASS_DROPDOWNLISTITEM;
1940+
const dropdownItem = fixture.debugElement.queryAll(By.css('.' + itemClass))[itemIndex];
1941+
const itemCheckbox = dropdownItem.query(By.css('.' + CSS_CLASS_ITEM_CHECKBOX));
1942+
itemCheckbox.triggerEventHandler('click', UIInteractions.getMouseEvent('click'));
1943+
fixture.detectChanges();
1944+
};
19361945
it('should append/remove selected items to the input in their selection order', () => {
19371946
let expectedOutput = 'Illinois';
19381947
combo.select(['Illinois']);
@@ -2028,7 +2037,7 @@ describe('igxCombo', () => {
20282037
fixture.detectChanges();
20292038

20302039
const selectedItem_1 = dropdown.items[1];
2031-
simulateComboItemCheckboxClick(1);
2040+
simulateComboItemClick(1);
20322041
expect(combo.selection[0]).toEqual(selectedItem_1.value.field);
20332042
expect(selectedItem_1.selected).toBeTruthy();
20342043
expect(selectedItem_1.element.nativeElement.classList.contains(CSS_CLASS_SELECTED)).toBeTruthy();
@@ -2046,7 +2055,7 @@ describe('igxCombo', () => {
20462055
});
20472056

20482057
const selectedItem_2 = dropdown.items[5];
2049-
simulateComboItemCheckboxClick(5);
2058+
simulateComboItemClick(5);
20502059
expect(combo.selection[1]).toEqual(selectedItem_2.value.field);
20512060
expect(selectedItem_2.selected).toBeTruthy();
20522061
expect(selectedItem_2.element.nativeElement.classList.contains(CSS_CLASS_SELECTED)).toBeTruthy();
@@ -2065,7 +2074,7 @@ describe('igxCombo', () => {
20652074

20662075
// Unselecting an item
20672076
const unselectedItem = dropdown.items[1];
2068-
simulateComboItemCheckboxClick(1);
2077+
simulateComboItemClick(1);
20692078
expect(combo.selection.length).toEqual(1);
20702079
expect(unselectedItem.selected).toBeFalsy();
20712080
expect(unselectedItem.element.nativeElement.classList.contains(CSS_CLASS_SELECTED)).toBeFalsy();
@@ -2087,10 +2096,26 @@ describe('igxCombo', () => {
20872096
combo.toggle();
20882097
fixture.detectChanges();
20892098

2090-
simulateComboItemCheckboxClick(0, true);
2099+
simulateComboItemClick(0, true);
20912100
expect(combo.selection.length).toEqual(0);
20922101
expect(combo.selectionChanging.emit).toHaveBeenCalledTimes(0);
20932102
});
2103+
it('should prevent selection when selectionChanging is cancelled', () => {
2104+
spyOn(combo.selectionChanging, 'emit').and.callFake((event: IComboSelectionChangingEventArgs) => event.cancel = true);
2105+
combo.toggle();
2106+
fixture.detectChanges();
2107+
2108+
const dropdownFirstItem = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_DROPDOWNLISTITEM}`))[0].nativeElement;
2109+
const itemCheckbox = dropdownFirstItem.querySelectorAll(`.${CSS_CLASS_ITEM_CHECKBOX}`);
2110+
2111+
simulateComboItemCheckboxClick(0);
2112+
expect(combo.selection.length).toEqual(0);
2113+
expect(itemCheckbox[0].classList.contains(CSS_CLASS_ITME_CHECKBOX_CHECKED)).toBeFalsy();
2114+
2115+
simulateComboItemClick(0);
2116+
expect(combo.selection.length).toEqual(0);
2117+
expect(itemCheckbox[0].classList.contains(CSS_CLASS_ITME_CHECKBOX_CHECKED)).toBeFalsy();
2118+
});
20942119
});
20952120
describe('Grouping tests: ', () => {
20962121
configureTestSuite();

projects/igniteui-angular/src/lib/core/styles/components/grid/_grid-component.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,14 @@
591591
@extend %igx-grid__tr-header-row !optional;
592592
}
593593

594+
@include e(tr-pivot, $m: 'columnDimensionLeaf') {
595+
@extend %igx-grid__tr-pivot--columnDimensionLeaf !optional
596+
}
597+
598+
@include e(tr-pivot, $m: 'columnMultiRowSpan') {
599+
@extend %igx-grid__tr-pivot--columnMultiRowSpan !optional
600+
}
601+
594602
@include e(tr-pivot-toggle-icons) {
595603
@extend %igx-grid__tr-pivot-toggle-icons !optional;
596604
}

projects/igniteui-angular/src/lib/core/styles/components/grid/_grid-theme.scss

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,6 +2881,15 @@
28812881
flex-direction: column;
28822882
}
28832883

2884+
%grid-thead--virtualizationWrapper {
2885+
height: 100%;
2886+
}
2887+
2888+
%grid-thead--virtualizationContainer {
2889+
overflow: visible;
2890+
height: 100%;
2891+
}
2892+
28842893
%igx-grid__tr-pivot {
28852894
display: flex;
28862895
align-items: center;
@@ -3004,6 +3013,22 @@
30043013
display: inline-flex !important;
30053014
}
30063015

3016+
%igx-grid__tr-pivot--columnDimensionLeaf {
3017+
box-shadow: none;
3018+
3019+
igx-grid-header {
3020+
border: none;
3021+
}
3022+
}
3023+
3024+
%igx-grid__tr-pivot--columnMultiRowSpan {
3025+
igx-grid-header {
3026+
> * {
3027+
visibility: hidden;
3028+
}
3029+
}
3030+
}
3031+
30073032
%igx-grid__tr-header-row {
30083033
igx-pivot-row-dimension-header-group {
30093034
igx-pivot-row-dimension-header {

projects/igniteui-angular/src/lib/core/styles/components/grid/_header-row-component.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@
7777
@include m(pivot) {
7878
@extend %grid-thead--pivot !optional;
7979
}
80+
81+
@include m(virtualizationWrapper) {
82+
@extend %grid-thead--virtualizationWrapper !optional;
83+
}
84+
85+
@include m(virtualizationContainer) {
86+
@extend %grid-thead--virtualizationContainer !optional;
87+
}
8088
}
8189

8290
@include b(igx-grid-th) {

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,9 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
14551455
this.igxForOf = value;
14561456
}
14571457

1458+
@Input()
1459+
public igxGridForOfUniqueSizeCache = false;
1460+
14581461
public get igxGridForOf() {
14591462
return this.igxForOf;
14601463
}
@@ -1465,7 +1468,7 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
14651468
*/
14661469
public get sizesCache(): number[] {
14671470
if (this.igxForScrollOrientation === 'horizontal') {
1468-
if (this.syncService.isMaster(this)) {
1471+
if (this.igxGridForOfUniqueSizeCache || this.syncService.isMaster(this)) {
14691472
return this._sizesCache;
14701473
}
14711474
return this.syncService.sizesCache(this.igxForScrollOrientation);

projects/igniteui-angular/src/lib/grids/common/grid.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ export interface PivotGridType extends GridType {
639639
dimensionsChange: EventEmitter<IDimensionsChange>;
640640
valuesChange: EventEmitter<IValuesChange>;
641641
pivotKeys: IPivotKeys;
642+
hasMultipleValues: boolean;
642643
}
643644
export interface GridSVGIcon {
644645
name: string;

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
11831183
public footer: ElementRef;
11841184

11851185
public get headerContainer() {
1186-
return this.theadRow?.headerContainer;
1186+
return this.theadRow?.headerForOf;
11871187
}
11881188

11891189
public get headerSelectorContainer() {
@@ -6758,7 +6758,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
67586758

67596759
// eslint-disable-next-line prefer-const
67606760
for (let [row, set] of selectionMap) {
6761-
row = this.paginator && source === this.filteredSortedData ? row + (this.paginator.perPage * this.paginator.page) : row;
6761+
row = this.paginator && (this.pagingMode === GridPagingMode.Local && source === this.filteredSortedData) ? row + (this.paginator.perPage * this.paginator.page) : row;
67626762
row = isRemote ? row - this.virtualizationState.startIndex : row;
67636763
if (!source[row] || source[row].detailsData !== undefined) {
67646764
continue;
@@ -7027,7 +7027,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
70277027
this.gridScroll.emit(args);
70287028
}
70297029

7030-
private horizontalScrollHandler(event) {
7030+
protected horizontalScrollHandler(event) {
70317031
const scrollLeft = event.target.scrollLeft;
70327032
this.headerContainer.onHScroll(scrollLeft);
70337033
this._horizontalForOfs.forEach(vfor => vfor.onHScroll(scrollLeft));

projects/igniteui-angular/src/lib/grids/headers/grid-header-group.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<ng-container *ngTemplateOutlet="column.headerTemplate ? column.headerTemplate : defaultColumn; context: { $implicit: column, column: column}">
6666
</ng-container>
6767
</div>
68-
<div class="igx-grid-thead__group">
68+
<div class="igx-grid-thead__group" *ngIf='!grid.isPivot'>
6969
<ng-container *ngFor="let child of column.children">
7070
<igx-grid-header-group *ngIf="!child.hidden" class="igx-grid-thead__subgroup"
7171
[ngClass]="child.headerGroupClasses"

0 commit comments

Comments
 (0)