Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ export var registerConfig = [
methods: [
"getRowByIndex",
"getRowByKey",
"getSelectedData",
"getCellByColumn",
"getCellByKey",
"pinRow",
Expand Down Expand Up @@ -628,7 +629,6 @@ export var registerConfig = [
"clearCellSelection",
"selectRange",
"getSelectedRanges",
"getSelectedData",
"selectedColumns",
"selectColumns",
"deselectColumns",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7498,7 +7498,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 @@ -818,6 +818,22 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
.reduce((a, b) => a.concat(b), []);
}

/**
* Returns an array of the current cell selection.
*/
public override getSelectedData(formatters = false, headers = false): any[] {
const source: any[] = [];
this.dataView.forEach((record) => {
if (this.isChildGridRecord(record)) {
source.push(null);
return;
}
const rowData = record as any;
source.push(this.isGhostRecord(rowData) || this.isRecordMerged(rowData) ? rowData.recordRef : rowData);
});
return this.extractDataFromSelection(source, formatters, headers);
}

/**
* Returns a `CellType` object that matches the conditions.
*
Expand Down Expand Up @@ -1181,7 +1197,6 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseDirecti
super.initColumns(collection, cb);
}


protected override setupColumns() {
if (this.parentIsland && this.parentIsland.childColumns.length > 0 && !this.autoGenerate) {
this.createColumnsList(this.parentIsland.childColumns.toArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IgxHierarchicalRowComponent } from './hierarchical-row.component';
import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition';
import { take } from 'rxjs/operators';
import {
IgxHierarchicalGridEmptyDataExportComponent,
IgxHierarchicalGridTestBaseComponent,
IgxHierarchicalGridTestCustomToolbarComponent,
IgxHierarchicalGridTestInputPaginatorComponent,
Expand Down Expand Up @@ -36,6 +37,7 @@ describe('IgxHierarchicalGrid Integration #hGrid', () => {
TestBed.configureTestingModule({
imports: [
NoopAnimationsModule,
IgxHierarchicalGridEmptyDataExportComponent,
IgxHierarchicalGridTestBaseComponent,
IgxHierarchicalGridTestCustomToolbarComponent,
IgxHierarchicalGridWithTransactionProviderComponent,
Expand Down Expand Up @@ -160,6 +162,39 @@ 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;
Comment thread
georgianastasov marked this conversation as resolved.
const targetRow = grid.dataRowList.toArray()
.find(row => row.data.Artist === targetArtist) as IgxHierarchicalRowComponent | undefined;

expect(targetRow).toBeDefined();
targetRow!.toggle();
tick(DEBOUNCE_TIME);
Comment thread
georgianastasov marked this conversation as resolved.
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