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 @@ -52,10 +52,7 @@ export class CharSeparatedValueData {
this._escapeCharacters.push(this._delimiter);

const headers = columns && columns.length ?
/* When column groups are present, always use the field as it indicates the group the column belongs to.
* Otherwise, in PivotGrid scenarios we can end up with many duplicated column names without a hint what they represent.
*/
columns.map(c => c.columnGroupParent ? c.field : c.header ?? c.field) :
columns.map(c => c.header ?? c.field) :
keys;

this._headerRecord = this.processHeaderRecord(headers, this._data.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { wait } from '../../test-utils/ui-interactions.spec';
import { IgxPivotGridComponent } from '../../grids/pivot-grid/pivot-grid.component';
import { IgxPivotGridTestBaseComponent } from '../../test-utils/pivot-grid-samples.spec';
import { IgxPivotNumericAggregate } from '../../grids/pivot-grid/pivot-grid-aggregate';
import { OneGroupThreeColsGridComponent } from '../../test-utils/grid-mch-sample.spec';

describe('CSV Grid Exporter', () => {
let exporter: IgxCsvExporterService;
Expand Down Expand Up @@ -391,6 +392,20 @@ describe('CSV Grid Exporter', () => {
expect(ExportUtilities.saveBlobToFile).toHaveBeenCalledTimes(1);
});

it('should print column headers when available when column groups are present.', async () => {
const fix = TestBed.createComponent(OneGroupThreeColsGridComponent);
fix.componentInstance.data = [];
fix.detectChanges();

fix.componentInstance.grid.getColumnByName('City').header = 'Test Header';
fix.detectChanges();

const grid = fix.componentInstance.grid;

const wrapper = await getExportedData(grid, options);
wrapper.verifyData('Country,Region,Test Header', 'Only headers should be exported.');
});

describe('Tree Grid CSV export', () => {
let fix;
let treeGrid: IgxTreeGridComponent;
Expand Down
Loading