Skip to content

Commit 365145f

Browse files
authored
Merge pull request #12907 from IgniteUI/dpetev/grid-public-api-take-two
refactor(grids): convert groupsRecords to getter, remove filteredData setter
2 parents c23454d + 9da13ce commit 365145f

File tree

7 files changed

+25
-110
lines changed

7 files changed

+25
-110
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export interface IPathSegment {
4949

5050
export interface IGridDataBindable {
5151
data: any[] | null;
52-
filteredData: any[];
52+
get filteredData(): any[];
5353
}
5454

5555
export interface CellType {
@@ -565,7 +565,7 @@ export interface GridType extends IGridDataBindable {
565565
groupingExpressions?: IGroupingExpression[];
566566
groupingExpressionsChange?: EventEmitter<IGroupingExpression[]>;
567567
groupsExpanded?: boolean;
568-
groupsRecords?: IGroupByRecord[];
568+
readonly groupsRecords?: IGroupByRecord[];
569569
groupingFlatResult?: any[];
570570
groupingResult?: any[];
571571
groupingMetadata?: any[];

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
17661766

17671767
if (this.filteringService.isFilteringExpressionsTreeEmpty(this._filteringExpressionsTree) &&
17681768
this.filteringService.isFilteringExpressionsTreeEmpty(this._advancedFilteringExpressionsTree)) {
1769-
this.filteredData = null;
1769+
this._filteredData = null;
17701770
}
17711771

17721772
this.filteringService.refreshExpressions();
@@ -1803,7 +1803,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
18031803

18041804
if (this.filteringService.isFilteringExpressionsTreeEmpty(this._filteringExpressionsTree) &&
18051805
this.filteringService.isFilteringExpressionsTreeEmpty(this._advancedFilteringExpressionsTree)) {
1806-
this.filteredData = null;
1806+
this._filteredData = null;
18071807
}
18081808

18091809
this.selectionService.clearHeaderCBState();
@@ -3114,6 +3114,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
31143114
private _rowEditable = false;
31153115
private _currentRowState: any;
31163116
private _filteredSortedData = null;
3117+
private _filteredData = null;
31173118

31183119
private _customDragIndicatorIconTemplate: TemplateRef<IgxGridEmptyTemplateContext>;
31193120
private _excelStyleHeaderIconTemplate: TemplateRef<IgxGridHeaderTemplateContext>;
@@ -3216,7 +3217,19 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
32163217
*/
32173218
public abstract id: string;
32183219
public abstract data: any[] | null;
3219-
public abstract filteredData: any[];
3220+
3221+
/**
3222+
* Returns an array of objects containing the filtered data.
3223+
*
3224+
* @example
3225+
* ```typescript
3226+
* let filteredData = this.grid.filteredData;
3227+
* ```
3228+
*/
3229+
public get filteredData() {
3230+
return this._filteredData;
3231+
}
3232+
32203233
/**
32213234
* Returns an array containing the filtered sorted data.
32223235
*
@@ -3730,11 +3743,11 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
37303743
this._filteredPinnedData = data || [];
37313744
const filteredUnpinned = this._filteredUnpinnedData || [];
37323745
const filteredData = [... this._filteredPinnedData, ...filteredUnpinned];
3733-
this.filteredData = filteredData.length > 0 ? filteredData : this._filteredUnpinnedData;
3746+
this._filteredData = filteredData.length > 0 ? filteredData : this._filteredUnpinnedData;
37343747
} else if (this.hasPinnedRecords && !pinned) {
37353748
this._filteredUnpinnedData = data;
37363749
} else {
3737-
this.filteredData = data;
3750+
this._filteredData = data;
37383751
}
37393752
}
37403753

projects/igniteui-angular/src/lib/grids/grid/grid.component.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
242242
@ViewChildren(IgxGridGroupByRowComponent, { read: IgxGridGroupByRowComponent })
243243
private _groupsRowList: QueryList<IgxGridGroupByRowComponent>;
244244

245+
private _groupsRecords: IGroupByRecord[] = [];
245246
/**
246247
* Gets the hierarchical representation of the group by records.
247248
*
@@ -250,7 +251,9 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
250251
* let groupRecords = this.grid.groupsRecords;
251252
* ```
252253
*/
253-
public groupsRecords: IGroupByRecord[] = [];
254+
public get groupsRecords(): IGroupByRecord[] {
255+
return this._groupsRecords;
256+
}
254257

255258
/**
256259
* @hidden @internal
@@ -331,23 +334,6 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
331334
}
332335
}
333336

334-
/**
335-
* Gets/Sets an array of objects containing the filtered data.
336-
*
337-
* @example
338-
* ```typescript
339-
* let filteredData = this.grid.filteredData;
340-
* this.grid.filteredData = [...];
341-
* ```
342-
*/
343-
public get filteredData() {
344-
return this._filteredData;
345-
}
346-
347-
public set filteredData(value) {
348-
this._filteredData = value;
349-
}
350-
351337
/**
352338
* Gets/Sets the total number of records in the data source.
353339
*
@@ -371,7 +357,6 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
371357
private get _gridAPI(): IgxGridAPIService {
372358
return this.gridAPI as IgxGridAPIService;
373359
}
374-
private _filteredData = null;
375360

376361
private childDetailTemplates: Map<any, any> = new Map();
377362

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.component.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class IgxChildGridRowComponent implements AfterViewInit, OnInit {
9595
@Input()
9696
public index: number;
9797

98-
@ViewChild('container', {read: ViewContainerRef, static: true})
98+
@ViewChild('container', {read: ViewContainerRef, static: true})
9999
public container: ViewContainerRef;
100100

101101
/**
@@ -337,7 +337,6 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
337337
public childRow: IgxChildGridRowComponent;
338338

339339
private _data;
340-
private _filteredData = null;
341340
private h_id = `igx-hierarchical-grid-${NEXT_ID++}`;
342341
private childGridTemplates: Map<any, any> = new Map();
343342
private scrollTop = 0;
@@ -411,33 +410,6 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
411410
super.excelStyleFilteringComponent;
412411
}
413412

414-
/**
415-
* Sets an array of objects containing the filtered data in the `IgxHierarchicalGridComponent`.
416-
* ```typescript
417-
* this.grid.filteredData = [{
418-
* ID: 1,
419-
* Name: "A"
420-
* }];
421-
* ```
422-
*
423-
* @memberof IgxHierarchicalGridComponent
424-
*/
425-
public set filteredData(value) {
426-
this._filteredData = value;
427-
}
428-
429-
/**
430-
* Returns an array of objects containing the filtered data in the `IgxHierarchicalGridComponent`.
431-
* ```typescript
432-
* let filteredData = this.grid.filteredData;
433-
* ```
434-
*
435-
* @memberof IgxHierarchicalGridComponent
436-
*/
437-
public get filteredData() {
438-
return this._filteredData;
439-
}
440-
441413
/**
442414
* Gets/Sets the total number of records in the data source.
443415
*

projects/igniteui-angular/src/lib/grids/hierarchical-grid/row-island.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
144144
*/
145145
public rootGrid: GridType = null;
146146
public readonly data: any[] | null;
147-
public readonly filteredData: any[];
148147

149148
private ri_columnListDiffer;
150149
private layout_id = `igx-row-island-`;

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,6 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
547547
protected override _defaultExpandState = false;
548548
protected override _filterStrategy: IFilteringStrategy = new DimensionValuesFilteringStrategy();
549549
private _data;
550-
private _filteredData;
551550
private _pivotConfiguration: IPivotConfiguration = { rows: null, columns: null, values: null, filters: null };
552551
private p_id = `igx-pivot-grid-${NEXT_ID++}`;
553552
private _superCompactMode = false;
@@ -1089,31 +1088,6 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
10891088
public get data(): any[] | null {
10901089
return this._data;
10911090
}
1092-
/**
1093-
* Sets an array of objects containing the filtered data.
1094-
* ```typescript
1095-
* this.grid.filteredData = [{
1096-
* ID: 1,
1097-
* Name: "A"
1098-
* }];
1099-
* ```
1100-
*/
1101-
public set filteredData(value) {
1102-
this._filteredData = value;
1103-
}
1104-
1105-
/**
1106-
* Returns an array of objects containing the filtered data.
1107-
* ```typescript
1108-
* let filteredData = this.grid.filteredData;
1109-
* ```
1110-
*
1111-
* @memberof IgxHierarchicalGridComponent
1112-
*/
1113-
public get filteredData() {
1114-
return this._filteredData;
1115-
}
1116-
11171091

11181092
/**
11191093
* @hidden

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ export class IgxTreeGridComponent extends IgxGridBaseDirective implements GridTy
271271
private _data;
272272
private _rowLoadingIndicatorTemplate: TemplateRef<void>;
273273
private _expansionDepth = Infinity;
274-
private _filteredData = null;
275274

276275
/**
277276
* An @Input property that lets you fill the `IgxTreeGridComponent` with an array of data.
@@ -295,33 +294,6 @@ export class IgxTreeGridComponent extends IgxGridBaseDirective implements GridTy
295294
this.cdr.markForCheck();
296295
}
297296

298-
/**
299-
* Returns an array of objects containing the filtered data in the `IgxGridComponent`.
300-
* ```typescript
301-
* let filteredData = this.grid.filteredData;
302-
* ```
303-
*
304-
* @memberof IgxTreeGridComponent
305-
*/
306-
public get filteredData() {
307-
return this._filteredData;
308-
}
309-
310-
/**
311-
* Sets an array of objects containing the filtered data in the `IgxGridComponent`.
312-
* ```typescript
313-
* this.grid.filteredData = [{
314-
* ID: 1,
315-
* Name: "A"
316-
* }];
317-
* ```
318-
*
319-
* @memberof IgxTreeGridComponent
320-
*/
321-
public set filteredData(value) {
322-
this._filteredData = value;
323-
}
324-
325297
/**
326298
* Get transactions service for the grid.
327299
*

0 commit comments

Comments
 (0)