diff --git a/projects/igniteui-angular/src/lib/grids/grid-base.component.ts b/projects/igniteui-angular/src/lib/grids/grid-base.component.ts
index 0a26f7bd3df..669aee924d1 100644
--- a/projects/igniteui-angular/src/lib/grids/grid-base.component.ts
+++ b/projects/igniteui-angular/src/lib/grids/grid-base.component.ts
@@ -340,8 +340,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
if (this.rowSelectable) {
this.updateHeaderCheckboxStatusOnFilter(this._filteredData);
}
-
- this.refreshSearch(true);
}
/**
@@ -1646,8 +1644,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
set sortingExpressions(value: ISortingExpression[]) {
this._sortingExpressions = cloneArray(value);
this.cdr.markForCheck();
-
- this.refreshSearch(true);
}
/**
@@ -2166,6 +2162,7 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
protected _wheelListener = null;
protected _allowFiltering = false;
private _filteredData = null;
+ private _filteredSortedData = null;
private resizeHandler;
private columnListDiffer;
private _hiddenColumnsText = '';
@@ -3012,8 +3009,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
this.onRowAdded.emit({ data });
this._pipeTrigger++;
this.cdr.markForCheck();
-
- this.refreshSearch();
}
/**
@@ -3070,7 +3065,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
// Data needs to be recalculated if transactions are in place
// If no transactions, `data` will be a reference to the grid getter, otherwise it will be stale
const dataAfterDelete = this.transactions.enabled ? this.dataWithAddedInTransactionRows : data;
- this.refreshSearch();
if (dataAfterDelete.length % this.perPage === 0 && dataAfterDelete.length / this.perPage - 1 < this.page && this.page !== 0) {
this.page--;
}
@@ -3122,7 +3116,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
this.gridAPI.escape_editMode(this.id, editableCell.cellID);
}
this.cdr.markForCheck();
- this.refreshSearch();
}
}
}
@@ -3148,7 +3141,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
}
this.gridAPI.update_row(value, this.id, rowSelector);
this.cdr.markForCheck();
- this.refreshSearch();
}
}
@@ -4197,30 +4189,18 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
}
/**
- * Returns an array containing the filtered data.
+ * Returns an array containing the filtered sorted data.
* ```typescript
- * const filteredData = this.grid1.filteredSortedData;
+ * const filteredSortedData = this.grid1.filteredSortedData;
* ```
* @memberof IgxGridBaseComponent
*/
get filteredSortedData(): any[] {
- return this.resolveFilteredSortedData();
+ return this._filteredSortedData;
}
-
- /**
- * @hidden
- */
- protected resolveFilteredSortedData(): any[] {
- let data: any[] = this.filteredData ? this.filteredData : this.data;
- if (!this.filteredData && this.transactions.enabled) {
- data = DataUtil.mergeTransactions(
- cloneArray(data),
- this.transactions.getAggregatedChanges(true),
- this.primaryKey
- );
- }
-
- return data;
+ set filteredSortedData(value: any[]) {
+ this._filteredSortedData = value;
+ this.refreshSearch(true);
}
/**
diff --git a/projects/igniteui-angular/src/lib/grids/grid/grid.component.html b/projects/igniteui-angular/src/lib/grids/grid/grid.component.html
index d1a7a38ae48..c47de54d688 100644
--- a/projects/igniteui-angular/src/lib/grids/grid/grid.component.html
+++ b/projects/igniteui-angular/src/lib/grids/grid/grid.component.html
@@ -71,7 +71,7 @@
0" [igxColumnMovingDrop]="parentVirtDir" [attr.droppable]="true" id="left" class="igx-grid__scroll-on-drag-pinned" [style.left.px]="pinnedWidth">
): void {
this._gridAPI.clear_groupby(this.id, name);
this.calculateGridSizes();
- this.refreshSearch(true);
}
/**
@@ -719,21 +717,6 @@ export class IgxGridComponent extends IgxGridBaseComponent implements OnInit, Do
super.scrollTo(row, column);
}
- /**
- * @hidden
- */
- protected resolveFilteredSortedData(): any[] {
- let data: any[] = super.resolveFilteredSortedData();
-
- if (this.sortingExpressions &&
- this.sortingExpressions.length > 0) {
-
- const sortingPipe = new IgxGridSortingPipe();
- data = sortingPipe.transform(data, this.sortingExpressions, -1);
- }
- return data;
- }
-
/**
* @hidden
*/
diff --git a/projects/igniteui-angular/src/lib/grids/grid/grid.pipes.ts b/projects/igniteui-angular/src/lib/grids/grid/grid.pipes.ts
index cd94980b975..3c54d52cc69 100644
--- a/projects/igniteui-angular/src/lib/grids/grid/grid.pipes.ts
+++ b/projects/igniteui-angular/src/lib/grids/grid/grid.pipes.ts
@@ -19,15 +19,24 @@ import { IgxGridBaseComponent } from '../grid-base.component';
pure: true
})
export class IgxGridSortingPipe implements PipeTransform {
+ private gridAPI: IgxGridAPIService;
+
+ constructor(gridAPI: GridBaseAPIService) {
+ this.gridAPI = gridAPI;
+ }
- constructor() { }
+ public transform(collection: any[], expressions: ISortingExpression[], id: string, pipeTrigger: number): any[] {
+ const grid = this.gridAPI.get(id);
+ let result: any[];
- public transform(collection: any[], expressions: ISortingExpression[], pipeTrigger: number): any[] {
if (!expressions.length) {
- return collection;
+ result = collection;
+ } else {
+ result = DataUtil.sort(cloneArray(collection), expressions);
}
+ grid.filteredSortedData = result;
- return DataUtil.sort(cloneArray(collection), expressions);
+ return result;
}
}
diff --git a/projects/igniteui-angular/src/lib/grids/row.component.ts b/projects/igniteui-angular/src/lib/grids/row.component.ts
index e382bf1871e..f4a072740c8 100644
--- a/projects/igniteui-angular/src/lib/grids/row.component.ts
+++ b/projects/igniteui-angular/src/lib/grids/row.component.ts
@@ -264,7 +264,6 @@ export class IgxRowComponent implements DoCheck
}
this.gridAPI.update_row(value, this.gridID, this.rowID);
this.cdr.markForCheck();
- this.grid.refreshSearch();
}
/**
diff --git a/projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.ts b/projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.ts
index fe4dd9768e7..03234ced4b2 100644
--- a/projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.ts
+++ b/projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.ts
@@ -93,11 +93,6 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
*/
public flatData: any[];
- /**
- * @hidden
- */
- public processedFlatData: any[];
-
/**
* @hidden
*/
@@ -389,8 +384,6 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
this.onRowAdded.emit({ data });
this._pipeTrigger++;
this.cdr.markForCheck();
-
- this.refreshSearch();
}
} else {
if (this.primaryKey && this.foreignKey) {
@@ -479,13 +472,6 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent {
return path.reverse();
}
- /**
- * @hidden
- */
- protected resolveFilteredSortedData(): any[] {
- return this.processedFlatData;
- }
-
/**
* @hidden
*/
diff --git a/projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.pipes.ts b/projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.pipes.ts
index fd20e0a4a0d..d92e5696130 100644
--- a/projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.pipes.ts
+++ b/projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.pipes.ts
@@ -142,7 +142,6 @@ export class IgxTreeGridFlatteningPipe implements PipeTransform {
grid.processedRootRecords = collection;
grid.processedRecords = new Map();
- grid.processedFlatData = [];
this.getFlatDataRecursive(collection, data, expandedLevels, expandedStates, id, true);
@@ -172,7 +171,6 @@ export class IgxTreeGridFlatteningPipe implements PipeTransform {
this.updateNonProcessedRecordExpansion(grid, hierarchicalRecord);
grid.processedRecords.set(hierarchicalRecord.rowID, hierarchicalRecord);
- grid.processedFlatData.push(hierarchicalRecord.data);
this.getFlatDataRecursive(hierarchicalRecord.children, data, expandedLevels,
expandedStates, gridID, parentExpanded && hierarchicalRecord.expanded);
@@ -210,9 +208,21 @@ export class IgxTreeGridSortingPipe implements PipeTransform {
} else {
result = DataUtil.treeGridSort(hierarchicalData, expressions);
}
+ const filteredSortedData = [];
+ this.flattenTreeGridRecords(result, filteredSortedData);
+ grid.filteredSortedData = filteredSortedData;
return result;
}
+
+ private flattenTreeGridRecords(records: ITreeGridRecord[], flatData: any[]) {
+ if (records && records.length) {
+ for (const record of records) {
+ flatData.push(record.data);
+ this.flattenTreeGridRecords(record.children, flatData);
+ }
+ }
+ }
}
/** @hidden */