Skip to content

Commit c3ae8fa

Browse files
authored
Merge branch 'master' into mkirova/fix-pinned-area-changes
2 parents b6b5921 + 346c14d commit c3ae8fa

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
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/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/grid-base.directive.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
24602460
protected _filteredSortedPinnedData;
24612461
protected _filteredSortedUnpinnedData;
24622462
protected _filteredPinnedData;
2463-
protected _filteredUnpinnedData;
2463+
2464+
/**
2465+
* @hidden
2466+
*/
2467+
public _filteredUnpinnedData;
24642468

24652469
/**
24662470
* @hidden
@@ -2879,10 +2883,6 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
28792883
this.summaryService.summaryHeight = 0;
28802884
this.notifyChanges(true);
28812885
});
2882-
2883-
this.onRowPinning.subscribe(() => {
2884-
this.summaryService.clearSummaryCache();
2885-
});
28862886
}
28872887

28882888
/**
@@ -2937,7 +2937,8 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
29372937
if (this.hasPinnedRecords && pinned) {
29382938
this._filteredPinnedData = data || [];
29392939
const filteredUnpinned = this._filteredUnpinnedData || [];
2940-
this.filteredData = [... this._filteredPinnedData, ... filteredUnpinned];
2940+
const filteredData = [... this._filteredPinnedData, ... filteredUnpinned];
2941+
this.filteredData = filteredData.length > 0 ? filteredData : this._filteredUnpinnedData;
29412942
} else if (this.hasPinnedRecords && !pinned) {
29422943
this._filteredUnpinnedData = data;
29432944
} else {

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

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

362+
it('should calculate global summaries correctly when filtering is applied.', () => {
363+
grid.getColumnByName('ID').hasSummary = true;
364+
fix.detectChanges();
365+
grid.filter('ID', 'BERGS', IgxStringFilteringOperand.instance().condition('contains'), false);
366+
fix.detectChanges();
367+
368+
let summaryRow = GridSummaryFunctions.getRootSummaryRow(fix);
369+
GridSummaryFunctions.verifyColumnSummaries(summaryRow, 0, ['Count'], ['1']);
370+
371+
// pin row
372+
grid.getRowByIndex(0).pin();
373+
fix.detectChanges();
374+
375+
summaryRow = GridSummaryFunctions.getRootSummaryRow(fix);
376+
GridSummaryFunctions.verifyColumnSummaries(summaryRow, 0, ['Count'], ['1']);
377+
});
378+
362379
it('should remove pinned container and recalculate sizes when all pinned records are filtered out.', () => {
363380
grid.getRowByIndex(1).pin();
364381
fix.detectChanges();

src/app/grid-row-pinning/grid-row-pinning.sample.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</igx-column>
4747
<igx-column *ngFor="let c of columns" [sortable]="true" [field]="c.field" [header]="c.field"
4848
[width]="c.width" [pinned]='c.pinned' [groupable]='c.groupable' [hidden]='c.hidden'
49-
[editable]='true'>
49+
[editable]='true' [hasSummary]='true'>
5050
</igx-column>
5151
</igx-grid>
5252
</div>
@@ -70,7 +70,7 @@
7070
<button (click)="hGrid.deleteRow(cell.cellID.rowID)">Delete</button>
7171
</ng-template>
7272
</igx-column>
73-
<igx-column *ngFor="let c of hColumns" [editable]="true" [sortable]="true" [field]="c.field" [header]="c.field" [width]="c.width" [pinned]='c.pinned' [groupable]='c.groupable' >
73+
<igx-column *ngFor="let c of hColumns" [hasSummary]='true' [editable]="true" [sortable]="true" [field]="c.field" [header]="c.field" [width]="c.width" [pinned]='c.pinned' [groupable]='c.groupable' >
7474
</igx-column>
7575
<igx-row-island [key]="'childData'" [autoGenerate]="true" [rowSelectable]='true' [allowFiltering]='true' >
7676
<igx-row-island [key]="'childData'" [autoGenerate]="true" [rowSelectable]='true' [allowFiltering]='true'></igx-row-island>
@@ -81,7 +81,7 @@
8181

8282
<div class="sample-column">
8383
<div>igxTreeGrid</div>
84-
<igx-tree-grid [pinning]="pinningConfig" #treegrid [allowFiltering]='true' [data]="treeData" primaryKey="employeeID" foreignKey="PID" [rowSelectable]="true"
84+
<igx-tree-grid [paging]='true' [pinning]="pinningConfig" #treegrid [allowFiltering]='true' [data]="treeData" primaryKey="employeeID" foreignKey="PID" [rowSelectable]="true"
8585
[width]="'900px'" [height]="'800px'" [showToolbar]="true"
8686
[columnHiding]="true" [columnPinning]="true" [exportExcel]="true" [exportCsv]="true" exportText="Export"
8787
>
@@ -94,7 +94,7 @@
9494
</igx-column>
9595
<igx-column *ngFor="let c of treeColumns" [field]="c.field" [dataType]="c.dataType" [header]="c.label"
9696
[pinned]="c.pinned" [movable]="c.movable" [groupable]="false" [resizable]="c.resizable" [width]="c.width"
97-
[sortable]="true" [filterable]="true" [editable]="true" [hidden]="c.hidden" [hasSummary]="c.hasSummary"
97+
[sortable]="true" [filterable]="true" [editable]="true" [hidden]="c.hidden"
9898
[minWidth]="c.minWidth" [maxWidth]="c.maxWidth">
9999
</igx-column>
100100

0 commit comments

Comments
 (0)