Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions projects/igniteui-angular/src/lib/grids/grid-base.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2411,6 +2411,8 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
*/
protected destroy$ = new Subject<any>();

protected _filteredSortedPinnedData;
protected _filteredSortedUnpinnedData;
protected _filteredPinnedData;
protected _filteredUnpinnedData;

Expand Down Expand Up @@ -2935,6 +2937,18 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
this.setupColumns();
}

public setFilteredSortedData(data, pinned: boolean) {
Comment thread
VMihalkov marked this conversation as resolved.
if (this._pinnedRecordIDs.length > 0 && pinned) {
this._filteredSortedPinnedData = data;
this.filteredSortedData = this.isRowPinningToTop ? [... this._filteredSortedPinnedData, ... this._filteredSortedUnpinnedData] :
[... this._filteredSortedUnpinnedData, ... this._filteredSortedPinnedData];
} else if (this._pinnedRecordIDs.length > 0 && !pinned) {
this._filteredSortedUnpinnedData = data;
} else {
this.filteredSortedData = data;
}
}

/**
* @hidden @internal
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
| visibleColumns:hasVisibleColumns
| rowPinning:id:true:pipeTrigger
| gridFiltering:filteringExpressionsTree:filterStrategy:advancedFilteringExpressionsTree:id:pipeTrigger:filteringPipeTrigger:true
| gridSort:sortingExpressions:sortStrategy:id:pipeTrigger
| gridSort:sortingExpressions:sortStrategy:id:pipeTrigger:true
| gridDetails:hasDetails:expansionStates:pipeTrigger as pinnedData'>
<div #pinContainer *ngIf='pinnedData.length > 0'
[ngClass]="{
Expand Down
4 changes: 2 additions & 2 deletions projects/igniteui-angular/src/lib/grids/grid/grid.pipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class IgxGridSortingPipe implements PipeTransform {
}

public transform(collection: any[], expressions: ISortingExpression[], sorting: IGridSortingStrategy,
id: string, pipeTrigger: number): any[] {
id: string, pipeTrigger: number, pinned?): any[] {
const grid = this.gridAPI.grid;
let result: any[];

Expand All @@ -38,7 +38,7 @@ export class IgxGridSortingPipe implements PipeTransform {
} else {
result = DataUtil.sort(cloneArray(collection), expressions, sorting);
}
grid.filteredSortedData = result;
grid.setFilteredSortedData(result, pinned);

return result;
}
Expand Down
36 changes: 36 additions & 0 deletions projects/igniteui-angular/src/lib/grids/grid/row-pinning.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,42 @@ describe('Row Pinning #grid', () => {
expect(grid.getRowByIndex(1).rowID).toBe(fix.componentInstance.data[1]);
});

it('should search in both pinned and unpinned rows.', () => {
// pin 1st row
let row = grid.getRowByIndex(0);
row.pinned = true;
fix.detectChanges();
expect(grid.pinnedRows.length).toBe(1);

let finds = grid.findNext('mari');
fix.detectChanges();

const fixNativeElement = fix.debugElement.nativeElement;
let spans = fixNativeElement.querySelectorAll('.igx-highlight');
expect(spans.length).toBe(1);
expect(finds).toEqual(2);

finds = grid.findNext('antonio');
fix.detectChanges();

spans = fixNativeElement.querySelectorAll('.igx-highlight');
expect(spans.length).toBe(2);
expect(finds).toEqual(2);

// pin 3rd row
row = grid.getRowByIndex(2);
row.pinned = true;
fix.detectChanges();
expect(grid.pinnedRows.length).toBe(2);

finds = grid.findNext('antonio');
fix.detectChanges();

spans = fixNativeElement.querySelectorAll('.igx-highlight');
expect(spans.length).toBe(2);
expect(finds).toEqual(2);
});

it('should allow pinning onInit', () => {
expect(() => {
fix = TestBed.createComponent(GridRowPinningComponent);
Expand Down