Skip to content

Commit c051787

Browse files
authored
Merge branch 'master' into mkirova/fix-pin-issue-treegrid
2 parents fc087d0 + 346c14d commit c051787

14 files changed

+85
-24
lines changed

projects/igniteui-angular/src/lib/grids/api.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
3434
public get_summary_data() {
3535
const grid = this.grid;
3636
let data = grid.filteredData;
37+
if (data && grid.hasPinnedRecords) {
38+
data = grid._filteredUnpinnedData;
39+
}
3740
if (!data) {
3841
if (grid.transactions.enabled) {
3942
data = DataUtil.mergeTransactions(

projects/igniteui-angular/src/lib/grids/columns/column.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ export class IgxColumnComponent implements AfterContentInit {
276276
this.grid.endEdit(false);
277277
this.grid.summaryService.resetSummaryHeight();
278278
this.grid.filteringService.refreshExpressions();
279+
this.grid.filteringService.hideFilteringRowOnColumnVisibilityChange(this);
279280
this.grid.notifyChanges();
280281
}
281282
}

projects/igniteui-angular/src/lib/grids/common/pipes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ export class IgxGridRowPinningPipe implements PipeTransform {
238238
}
239239

240240
grid.unpinnedRecords = collection;
241+
241242
return collection.map((rec) => {
242243
return grid.isRecordPinned(rec) ? { recordRef: rec, ghostRecord: true} : rec;
243244
});

projects/igniteui-angular/src/lib/grids/filtering/grid-filtering.service.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,17 @@ export class IgxFilteringService implements OnDestroy {
9797
filterCell.updateFilterCellArea();
9898
});
9999
});
100+
}
101+
}
100102

101-
this.grid.onColumnVisibilityChanged.pipe(takeUntil(this.destroy$)).subscribe((eventArgs: IColumnVisibilityChangedEventArgs) => {
102-
if (this.grid.filteringRow && this.grid.filteringRow.column === eventArgs.column ) {
103-
this.grid.filteringRow.close();
103+
/**
104+
* Close filtering row if a column is hidden.
105+
*/
106+
public hideFilteringRowOnColumnVisibilityChange(col: IgxColumnComponent) {
107+
const filteringRow = this.grid.filteringRow;
104108

105-
}
106-
});
109+
if (filteringRow && filteringRow.column && filteringRow.column === col) {
110+
filteringRow.close();
107111
}
108112
}
109113

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
24572457
protected _filteredSortedPinnedData;
24582458
protected _filteredSortedUnpinnedData;
24592459
protected _filteredPinnedData;
2460-
protected _filteredUnpinnedData;
2460+
2461+
/**
2462+
* @hidden
2463+
*/
2464+
public _filteredUnpinnedData;
24612465

24622466
/**
24632467
* @hidden
@@ -2875,10 +2879,6 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
28752879
this.summaryService.summaryHeight = 0;
28762880
this.notifyChanges(true);
28772881
});
2878-
2879-
this.onRowPinning.subscribe(() => {
2880-
this.summaryService.clearSummaryCache();
2881-
});
28822882
}
28832883

28842884
/**
@@ -2932,7 +2932,8 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
29322932
if (this.hasPinnedRecords && pinned) {
29332933
this._filteredPinnedData = data || [];
29342934
const filteredUnpinned = this._filteredUnpinnedData || [];
2935-
this.filteredData = [... this._filteredPinnedData, ... filteredUnpinned];
2935+
const filteredData = [... this._filteredPinnedData, ... filteredUnpinned];
2936+
this.filteredData = filteredData.length > 0 ? filteredData : this._filteredUnpinnedData;
29362937
} else if (this.hasPinnedRecords && !pinned) {
29372938
this._filteredUnpinnedData = data;
29382939
} else {

projects/igniteui-angular/src/lib/grids/grid/expandable-cell.component.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<ng-template #defaultPinnedIndicator>
2+
<igx-chip *ngIf="displayPinnedChip" class="igx-grid__td--pinned-chip" [disabled]="true" [displayDensity]="'compact'">{{ grid.resourceStrings.igx_grid_pinned_row_indicator }}</igx-chip>
3+
</ng-template>
14
<ng-template #defaultCell>
25
<div igxTextHighlight style="pointer-events: none" [cssClass]="highlightClass" [activeCssClass]="activeHighlightClass" [groupName]="gridID"
36
[value]="formatter ? formatter(value) : column.dataType === 'number' ? (value | igxdecimal: grid.locale) : column.dataType === 'date' ? (value | igxdate: grid.locale) : value"
@@ -33,6 +36,8 @@
3336
</ng-container>
3437
</div>
3538
</ng-container>
39+
<ng-container *ngTemplateOutlet="pinnedIndicatorTemplate; context: context">
40+
</ng-container>
3641
<ng-container *ngTemplateOutlet="template; context: context">
3742
</ng-container>
3843
<ng-template #defaultExpandedTemplate>

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,24 +2138,24 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
21382138
}));
21392139

21402140
it('Should close filter row when hide the current column', fakeAsync(() => {
2141-
pending('This issue is failing because of bug #');
21422141
GridFunctions.clickFilterCellChip(fix, 'ProductName');
21432142

21442143
// Check that the filterRow is opened
2145-
const filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
2144+
let filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
21462145
expect(filterUIRow).not.toBeNull();
21472146

21482147
// Add first chip.
21492148
GridFunctions.typeValueInFilterRowInput('a', fix);
21502149
tick(100);
21512150

21522151
grid.getColumnByName('ProductName').hidden = true;
2153-
fix.detectChanges();
21542152
tick(100);
2153+
fix.detectChanges();
21552154

21562155
// Check that the filterRow is closed
2157-
expect(fix.debugElement.query(By.css(FILTER_UI_ROW))).toBeNull();
2158-
expect(grid.rowList.length).toBe(8);
2156+
filterUIRow = fix.debugElement.query(By.css(FILTER_UI_ROW));
2157+
expect(filterUIRow).toBeNull();
2158+
expect(grid.rowList.length).toBe(3, 'filter is not applied');
21592159
}));
21602160

21612161
it('Should keep existing column filter after hiding another column.', fakeAsync(() => {

projects/igniteui-angular/src/lib/grids/grid/grid-row-pinning.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,23 @@ describe('Row Pinning #grid', () => {
358358
expect(pinRowContainer[0].children[0].context.rowID).toBe(fix.componentInstance.data[4]);
359359
});
360360

361+
it('should calculate global summaries correctly when filtering is applied.', () => {
362+
grid.getColumnByName('ID').hasSummary = true;
363+
fix.detectChanges();
364+
grid.filter('ID', 'BERGS', IgxStringFilteringOperand.instance().condition('contains'), false);
365+
fix.detectChanges();
366+
367+
let summaryRow = GridSummaryFunctions.getRootSummaryRow(fix);
368+
GridSummaryFunctions.verifyColumnSummaries(summaryRow, 0, ['Count'], ['1']);
369+
370+
// pin row
371+
grid.getRowByIndex(0).pin();
372+
fix.detectChanges();
373+
374+
summaryRow = GridSummaryFunctions.getRootSummaryRow(fix);
375+
GridSummaryFunctions.verifyColumnSummaries(summaryRow, 0, ['Count'], ['1']);
376+
});
377+
361378
it('should remove pinned container and recalculate sizes when all pinned records are filtered out.', () => {
362379
grid.getRowByIndex(1).pin();
363380
fix.detectChanges();
@@ -456,6 +473,9 @@ describe('Row Pinning #grid', () => {
456473
expect(grid.expansionStates.get(pinnedRow.rowID)).toBeTruthy();
457474
// disabled row should have expand icon
458475
expect(firstRowIconName).toEqual('expand_more');
476+
// disabled row should have chip
477+
const cell = grid.getRowByIndex(0).cells.first;
478+
expect(cell.nativeElement.getElementsByClassName('igx-grid__td--pinned-chip').length).toBe(1);
459479
// pinned row shouldn't have expand icon
460480
const hasIconForPinnedRow = pinnedRow.cells.first.nativeElement.querySelector('igx-icon');
461481
expect(hasIconForPinnedRow).toBeNull();

projects/igniteui-angular/src/lib/grids/state.directive.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,15 @@ describe('IgxGridState - input properties #grid', () => {
414414
expect(grid.pinnedRows[1].rowID).toBe(3);
415415
gridState = state.getState(true, 'rowPinning');
416416
expect(gridState).toBe(rowPinState);
417+
418+
grid.getRowByIndex(3).pin();
419+
420+
state.setState(rowPinStateObject);
421+
fix.detectChanges();
422+
423+
expect(grid.pinnedRows.length).toBe(2);
424+
expect(grid.pinnedRows[0].rowID).toBe(1);
425+
expect(grid.pinnedRows[1].rowID).toBe(3);
417426
});
418427

419428
it('setState should correctly restore grid cell selection state from string', () => {

projects/igniteui-angular/src/lib/grids/state.directive.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ export class IgxGridStateDirective {
478478
}
479479

480480
private restoreRowPinning(state: any[]) {
481+
// clear current state.
482+
this.grid.pinnedRows.forEach(row => row.unpin());
481483
state.forEach(rowID => this.grid.pinRow(rowID));
482484
}
483485

0 commit comments

Comments
 (0)