Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ttonev/fix 14970 19.0 #15223

Open
wants to merge 4 commits into
base: 19.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
25 changes: 25 additions & 0 deletions projects/igniteui-angular/src/lib/grids/grid-public-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 { IgxPivotGridRow } from '../grid-public-row';

let NEXT_ID = 0;
const MINIMUM_COLUMN_WIDTH = 200;
Expand Down Expand Up @@ -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 IgxPivotGridRow(this, index, rec);
}
return row;
}
}
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -2105,8 +2106,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', () => {
Expand Down
Loading