From 439ef6c04b2f51cc9d12f921e65d277b8d34811b Mon Sep 17 00:00:00 2001
From: ttonev <ttonev@infragistics.com>
Date: Tue, 7 Jan 2025 17:55:05 +0200
Subject: [PATCH 1/6] fix(pivot-grid): added createRow method for grid based
 events

---
 .../grids/pivot-grid/pivot-grid.component.ts    | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts
index 042519ef0c8..da0a153a5e3 100644
--- a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts
+++ b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts
@@ -102,6 +102,7 @@ import { IgxTextHighlightService } from '../../directives/text-highlight/text-hi
 import { IgxPivotRowHeaderGroupComponent } from './pivot-row-header-group.component';
 import { IgxPivotDateDimension } from './pivot-grid-dimensions';
 import { IgxPivotRowDimensionMrlRowComponent } from './pivot-row-dimension-mrl-row.component';
+import { IgxGridRow } from 'igniteui-angular';
 
 let NEXT_ID = 0;
 const MINIMUM_COLUMN_WIDTH = 200;
@@ -2510,4 +2511,20 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
             this.regroupTrigger++;
         }
     }
+
+    /**
+     * @hidden @internal
+     */
+     public createRow(index: number, data?: any): RowType {
+        let row: RowType;
+
+        const dataIndex = this._getDataViewIndex(index);
+        const rec = data ?? this.dataView[dataIndex];
+
+
+        if (!row && rec) {
+            row = new IgxGridRow(this, index, rec);
+        }
+        return row;
+    }
 }

From b9cc87db75aa074c828442d148a0223614ae436e Mon Sep 17 00:00:00 2001
From: ttonev <ttonev@infragistics.com>
Date: Thu, 9 Jan 2025 12:08:41 +0200
Subject: [PATCH 2/6] fix(pivot-grid): update import paths and add cell click
 event test

---
 .../grids/pivot-grid/pivot-grid.component.ts  |  2 +-
 .../lib/grids/pivot-grid/pivot-grid.spec.ts   | 20 +++++++++++++++++--
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts
index da0a153a5e3..9cbd650cbdd 100644
--- a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts
+++ b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts
@@ -102,7 +102,7 @@ import { IgxTextHighlightService } from '../../directives/text-highlight/text-hi
 import { IgxPivotRowHeaderGroupComponent } from './pivot-row-header-group.component';
 import { IgxPivotDateDimension } from './pivot-grid-dimensions';
 import { IgxPivotRowDimensionMrlRowComponent } from './pivot-row-dimension-mrl-row.component';
-import { IgxGridRow } from 'igniteui-angular';
+import { IgxGridRow } from '../grid-public-row';
 
 let NEXT_ID = 0;
 const MINIMUM_COLUMN_WIDTH = 200;
diff --git a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts
index 21b047ebe44..08febf81720 100644
--- a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts
+++ b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts
@@ -1,7 +1,7 @@
 import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
 import { By } from '@angular/platform-browser';
 import { NoopAnimationsModule } from '@angular/platform-browser/animations';
-import { FilteringExpressionsTree, FilteringLogic, GridColumnDataType, IgxIconComponent, IgxPivotGridComponent, IgxStringFilteringOperand } from 'igniteui-angular';
+import { CellType, FilteringExpressionsTree, FilteringLogic, GridColumnDataType, IGridCellEventArgs, IgxIconComponent, IgxPivotGridComponent, IgxStringFilteringOperand } from 'igniteui-angular';
 import { IgxChipComponent } from '../../chips/chip.component';
 import { IgxChipsAreaComponent } from '../../chips/chips-area.component';
 import { DefaultPivotSortingStrategy } from '../../data-operations/pivot-sort-strategy';
@@ -23,6 +23,7 @@ import { Size } from '../common/enums';
 import { setElementSize } from '../../test-utils/helper-utils.spec';
 import { IgxPivotRowDimensionMrlRowComponent } from './pivot-row-dimension-mrl-row.component';
 import { IgxPivotRowDimensionContentComponent } from './pivot-row-dimension-content.component';
+import { IgxGridCellComponent } from '../cell.component';
 
 const CSS_CLASS_LIST = 'igx-drop-down__list';
 const CSS_CLASS_ITEM = 'igx-drop-down__item';
@@ -2106,8 +2107,23 @@ describe('IgxPivotGrid #pivotGrid', () => {
 
                 expect(pivotGrid.rowList.length).toBe(10);
             });
-        });
 
+            it('should have the correct IGridCellEventArgs when clicking on a cell', () => {
+                const pivotGrid = fixture.componentInstance.pivotGrid;
+                spyOn(pivotGrid.cellClick, 'emit').and.callThrough();
+                fixture.detectChanges();
+
+                const cell = pivotGrid.gridAPI.get_cell_by_index(0, 'Bulgaria-UnitsSold') as CellType;
+
+                pivotGrid.cellClick.emit({ cell, event: null });
+                cell.nativeElement.click();
+                const cellClickargs: IGridCellEventArgs = { cell, event: new MouseEvent('click') };
+
+                const gridCell = cellClickargs.cell as  IgxGridCellComponent;
+                const firstEntry = gridCell.rowData.aggregationValues.entries().next().value;
+                expect(firstEntry).toEqual(['USA-UnitsSold', 829]);
+            });
+        });
     });
 
     describe('IgxPivotGrid complex hierarchy #pivotGrid', () => {

From f8305265efffb0605af12798e9c6bbed2a806db7 Mon Sep 17 00:00:00 2001
From: ttonev <ttonev@infragistics.com>
Date: Tue, 28 Jan 2025 17:32:19 +0200
Subject: [PATCH 3/6] fix(pivot): added IgxPivotGridRow

---
 .../src/lib/grids/grid-public-row.ts          | 25 +++++++++++++++++++
 .../grids/pivot-grid/pivot-grid.component.ts  |  4 +--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/projects/igniteui-angular/src/lib/grids/grid-public-row.ts b/projects/igniteui-angular/src/lib/grids/grid-public-row.ts
index 89a2cabe484..5ca1eac6fdc 100644
--- a/projects/igniteui-angular/src/lib/grids/grid-public-row.ts
+++ b/projects/igniteui-angular/src/lib/grids/grid-public-row.ts
@@ -791,3 +791,28 @@ export class IgxSummaryRow implements RowType {
         return row;
     }
 }
+
+export class IgxPivotGridRow extends BaseRow {
+    /**
+      * @hidden
+      */
+     constructor(
+         public override grid: GridType,
+         public override index: number, data?: any
+     ) {
+         super();
+         this._data = data && data.addRow && data.recordRef ? data.recordRef : data;
+     }
+
+     /**
+      * Gets the rendered cells in the row component.
+      */
+     public override get cells(): CellType[] {
+         const res: CellType[] = [];
+         this.grid.columns.forEach(col => {
+             const cell: CellType = new IgxGridCell(this.grid, this.index, col);
+             res.push(cell);
+         });
+         return res;
+     }
+ }
diff --git a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts
index 9cbd650cbdd..ace03b6ba78 100644
--- a/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts
+++ b/projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.ts
@@ -102,7 +102,7 @@ import { IgxTextHighlightService } from '../../directives/text-highlight/text-hi
 import { IgxPivotRowHeaderGroupComponent } from './pivot-row-header-group.component';
 import { IgxPivotDateDimension } from './pivot-grid-dimensions';
 import { IgxPivotRowDimensionMrlRowComponent } from './pivot-row-dimension-mrl-row.component';
-import { IgxGridRow } from '../grid-public-row';
+import { IgxPivotGridRow } from '../grid-public-row';
 
 let NEXT_ID = 0;
 const MINIMUM_COLUMN_WIDTH = 200;
@@ -2523,7 +2523,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
 
 
         if (!row && rec) {
-            row = new IgxGridRow(this, index, rec);
+            row = new IgxPivotGridRow(this, index, rec);
         }
         return row;
     }

From 6d59b29e93c0e920a5d98b072f2063de582c8d22 Mon Sep 17 00:00:00 2001
From: ttonev <ttonev@infragistics.com>
Date: Thu, 13 Feb 2025 16:58:22 +0200
Subject: [PATCH 4/6] fix(pivot-grid): refactor IgxPivotGridRow to implement
 RowType

---
 .../src/lib/grids/grid-public-row.ts          | 62 ++++++++++++-------
 1 file changed, 38 insertions(+), 24 deletions(-)

diff --git a/projects/igniteui-angular/src/lib/grids/grid-public-row.ts b/projects/igniteui-angular/src/lib/grids/grid-public-row.ts
index 5ca1eac6fdc..db549a456db 100644
--- a/projects/igniteui-angular/src/lib/grids/grid-public-row.ts
+++ b/projects/igniteui-angular/src/lib/grids/grid-public-row.ts
@@ -792,27 +792,41 @@ export class IgxSummaryRow implements RowType {
     }
 }
 
-export class IgxPivotGridRow extends BaseRow {
-    /**
-      * @hidden
-      */
-     constructor(
-         public override grid: GridType,
-         public override index: number, data?: any
-     ) {
-         super();
-         this._data = data && data.addRow && data.recordRef ? data.recordRef : data;
-     }
-
-     /**
-      * Gets the rendered cells in the row component.
-      */
-     public override get cells(): CellType[] {
-         const res: CellType[] = [];
-         this.grid.columns.forEach(col => {
-             const cell: CellType = new IgxGridCell(this.grid, this.index, col);
-             res.push(cell);
-         });
-         return res;
-     }
- }
+export class IgxPivotGridRow implements RowType {
+    public index: number;
+    public grid: GridType;
+    private _data?: any;
+
+    constructor(grid: GridType, index: number, data?: any) {
+        this.grid = grid;
+        this.index = index;
+        this._data = data && data.addRow && data.recordRef ? data.recordRef : data;
+    }
+
+    public get data(): any {
+        return this._data ?? this.grid.dataView[this.index];
+    }
+
+    public get viewIndex(): number {
+        return this.index + this.grid.page * this.grid.perPage;
+    }
+
+    public get key(): any {
+        const data = this._data ?? this.grid.dataView[this.index];
+        const primaryKey = this.grid.primaryKey;
+        return primaryKey ? data[primaryKey] : data;
+    }
+
+    public get selected(): boolean {
+        return this.grid.selectionService.isRowSelected(this.key);
+    }
+
+    public set selected(val: boolean) {
+        if (val) {
+            this.grid.selectionService.selectRowsWithNoEvent([this.key]);
+        } else {
+            this.grid.selectionService.deselectRowsWithNoEvent([this.key]);
+        }
+        this.grid.cdr.markForCheck();
+    }
+}

From 27b3da691a03a51d8254ee00934b22536179375a Mon Sep 17 00:00:00 2001
From: ttonev <ttonev@infragistics.com>
Date: Wed, 26 Feb 2025 16:05:07 +0200
Subject: [PATCH 5/6] fix(grid): added comments to public properties

---
 .../src/lib/grids/grid-public-row.ts          | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/projects/igniteui-angular/src/lib/grids/grid-public-row.ts b/projects/igniteui-angular/src/lib/grids/grid-public-row.ts
index db549a456db..c16b294b9bf 100644
--- a/projects/igniteui-angular/src/lib/grids/grid-public-row.ts
+++ b/projects/igniteui-angular/src/lib/grids/grid-public-row.ts
@@ -793,7 +793,13 @@ export class IgxSummaryRow implements RowType {
 }
 
 export class IgxPivotGridRow implements RowType {
+
+    /** The index of the row within the grid */
     public index: number;
+
+    /**
+     * The grid that contains the row.
+     */
     public grid: GridType;
     private _data?: any;
 
@@ -803,20 +809,43 @@ export class IgxPivotGridRow implements RowType {
         this._data = data && data.addRow && data.recordRef ? data.recordRef : data;
     }
 
+    /**
+     *  The data passed to the row component.
+     */
     public get data(): any {
         return this._data ?? this.grid.dataView[this.index];
     }
 
+    /**
+     * Returns the view index calculated per the grid page.
+     */
     public get viewIndex(): number {
         return this.index + this.grid.page * this.grid.perPage;
     }
 
+    /**
+     * Gets the row key.
+     * A row in the grid is identified either by:
+     * - primaryKey data value,
+     * - the whole rowData, if the primaryKey is omitted.
+     *
+     * ```typescript
+     * let rowKey = row.key;
+     * ```
+     */
     public get key(): any {
         const data = this._data ?? this.grid.dataView[this.index];
         const primaryKey = this.grid.primaryKey;
         return primaryKey ? data[primaryKey] : data;
     }
 
+    /**
+     * Gets whether the row is selected.
+     * Default value is `false`.
+     * ```typescript
+     * row.selected = true;
+     * ```
+     */
     public get selected(): boolean {
         return this.grid.selectionService.isRowSelected(this.key);
     }

From c9833234bc2fef54acc3705031df83ae1808ecce Mon Sep 17 00:00:00 2001
From: ttonev <ttonev@infragistics.com>
Date: Thu, 20 Mar 2025 09:28:10 +0200
Subject: [PATCH 6/6] fix(pivot-grid): update IgxPivotGridRow

---
 .../src/lib/grids/grid-public-row.ts                 | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/projects/igniteui-angular/src/lib/grids/grid-public-row.ts b/projects/igniteui-angular/src/lib/grids/grid-public-row.ts
index c16b294b9bf..88431321d9d 100644
--- a/projects/igniteui-angular/src/lib/grids/grid-public-row.ts
+++ b/projects/igniteui-angular/src/lib/grids/grid-public-row.ts
@@ -6,6 +6,8 @@ import { IgxSummaryResult } from './summaries/grid-summary';
 import { ITreeGridRecord } from './tree-grid/tree-grid.interfaces';
 import { mergeWith } from 'lodash-es';
 import { CellType, GridServiceType, GridType, IGridValidationState, RowType, ValidationStatus } from './common/grid.interface';
+import { IgxPivotGridComponent } from './pivot-grid/public_api';
+import { PivotUtil } from './pivot-grid/pivot-util';
 
 abstract class BaseRow implements RowType {
     public index: number;
@@ -800,10 +802,10 @@ export class IgxPivotGridRow implements RowType {
     /**
      * The grid that contains the row.
      */
-    public grid: GridType;
+    public grid: IgxPivotGridComponent;
     private _data?: any;
 
-    constructor(grid: GridType, index: number, data?: any) {
+    constructor(grid: IgxPivotGridComponent, index: number, data?: any) {
         this.grid = grid;
         this.index = index;
         this._data = data && data.addRow && data.recordRef ? data.recordRef : data;
@@ -834,9 +836,9 @@ export class IgxPivotGridRow implements RowType {
      * ```
      */
     public get key(): any {
-        const data = this._data ?? this.grid.dataView[this.index];
-        const primaryKey = this.grid.primaryKey;
-        return primaryKey ? data[primaryKey] : data;
+        const dimension = this.grid.visibleRowDimensions[this.grid.visibleRowDimensions.length - 1];
+        const recordKey =  PivotUtil.getRecordKey(this.data, dimension);
+        return recordKey ? recordKey : null;
     }
 
     /**