Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -7433,7 +7433,7 @@ export abstract class IgxGridBaseDirective implements GridType,
const keysAndData = [];
const activeEl = this.selectionService.activeElement;

if (this.type === 'hierarchical') {
if (this.type === 'hierarchical' && source === this.filteredSortedData) {
const expansionRowIndexes = [];
for (const [key, value] of this.expansionStates.entries()) {
if (value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,20 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
super.initColumns(collection, cb);
}

/**
* @hidden @internal
*/
Comment thread
georgianastasov marked this conversation as resolved.
Outdated
public override getSelectedData(formatters = false, headers = false): any[] {
const source: any[] = [];
this.dataView.forEach((record) => {
if (this.isChildGridRecord(record)) {
source.push(null);
return;
}
source.push(record);
});
return this.extractDataFromSelection(source, formatters, headers);
Comment thread
georgianastasov marked this conversation as resolved.
Outdated
}

protected override setupColumns() {
if (this.parentIsland && this.parentIsland.childColumns.length > 0 && !this.autoGenerate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { IgxColumnMovingDragDirective, IgxGridNavigationService } from 'igniteui
import { IgxHierarchicalRowComponent } from './hierarchical-row.component';
import { take } from 'rxjs/operators';
import {
IgxHierarchicalGridEmptyDataExportComponent,
IgxHierarchicalGridTestBaseComponent,
IgxHierarchicalGridTestCustomToolbarComponent,
IgxHierarchicalGridTestInputPaginatorComponent,
Expand Down Expand Up @@ -35,6 +36,7 @@ describe('IgxHierarchicalGrid Integration #hGrid', () => {
TestBed.configureTestingModule({
imports: [
NoopAnimationsModule,
IgxHierarchicalGridEmptyDataExportComponent,
IgxHierarchicalGridTestBaseComponent,
IgxHierarchicalGridTestCustomToolbarComponent,
IgxHierarchicalGridWithTransactionProviderComponent,
Expand Down Expand Up @@ -162,6 +164,38 @@ describe('IgxHierarchicalGrid Integration #hGrid', () => {
expect(fChildCell.selected).toBeFalsy();
expect(fCell.selected).toBeTruthy();
}));

it('should not copy the previous row value from an expanded parent row', fakeAsync(() => {
const singersFixture = TestBed.createComponent(IgxHierarchicalGridEmptyDataExportComponent);
const singersData = SampleTestData.hierarchicalGridSingersFullData();
(singersFixture.componentInstance as { data: unknown[] }).data = singersData;
singersFixture.detectChanges();

const grid = singersFixture.componentInstance.hGrid;

const previousArtist = singersData[1].Artist;
const targetArtist = singersData[2].Artist;
const targetRow = grid.dataRowList.toArray()
.find(row => row.data.Artist === targetArtist) as IgxHierarchicalRowComponent;

targetRow.toggle();
tick(DEBOUNCE_TIME);
singersFixture.detectChanges();

grid.selectRange({
rowStart: targetRow.index,
rowEnd: targetRow.index,
columnStart: 'Artist',
columnEnd: 'Artist'
});
singersFixture.detectChanges();

expect(targetRow.expanded).toBeTruthy();

const selectedData = grid.getSelectedData();
expect(selectedData).toEqual([{ Artist: targetArtist }]);
expect(selectedData[0].Artist).not.toBe(previousArtist);
}));
});

describe('Updating', () => {
Expand Down
Loading