igniteui-angular 21.0.0 → 21.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19471,10 +19471,7 @@ class CharSeparatedValueData {
19471
19471
  this._isSpecialData = ExportUtilities.isSpecialData(this._data[0]);
19472
19472
  this._escapeCharacters.push(this._delimiter);
19473
19473
  const headers = columns && columns.length ?
19474
- /* When column groups are present, always use the field as it indicates the group the column belongs to.
19475
- * Otherwise, in PivotGrid scenarios we can end up with many duplicated column names without a hint what they represent.
19476
- */
19477
- columns.map(c => c.columnGroupParent ? c.field : c.header ?? c.field) :
19474
+ columns.map(c => c.header ?? c.field) :
19478
19475
  keys;
19479
19476
  this._headerRecord = this.processHeaderRecord(headers, this._data.length);
19480
19477
  if (keys.length === 0 || ((!this._data || this._data.length === 0) && keys.length === 0)) {
@@ -19848,6 +19845,8 @@ class IgxPdfExporterService extends IgxBaseExporter {
19848
19845
  }
19849
19846
  // Draw data rows
19850
19847
  pdf.setFont('helvetica', 'normal');
19848
+ // Check if this is a tree grid export (tree grids can have both TreeGridRecord and DataRecord types for nested children)
19849
+ const isTreeGridExport = data.some(record => record.type === ExportRecordType.TreeGridRecord);
19851
19850
  // For pivot grids, get row dimension columns to help with value lookup
19852
19851
  const rowDimensionColumnsByLevel = new Map();
19853
19852
  if (isPivotGrid && defaultOwner) {
@@ -19892,11 +19891,13 @@ class IgxPdfExporterService extends IgxBaseExporter {
19892
19891
  // Calculate indentation for hierarchical records
19893
19892
  // TreeGrid supports both hierarchical data and flat self-referencing data (with foreignKey)
19894
19893
  // In both cases, the base exporter sets the level property on TreeGridRecord
19895
- const isTreeGrid = record.type === 'TreeGridRecord';
19894
+ // Note: Nested child records without children are created as DataRecord type,
19895
+ // but they still have a level property and should be treated as tree grid records
19896
19896
  const recordIsHierarchicalGrid = record.type === 'HierarchicalGridRecord';
19897
19897
  // For tree grids, indentation is visual (in the first column text)
19898
19898
  // For hierarchical grids, we don't use indentation (level determines column offset instead)
19899
- const indentLevel = isTreeGrid ? (record.level || 0) : 0;
19899
+ // If this is a tree grid export and the record has a level property, use it for indentation
19900
+ const indentLevel = (isTreeGridExport && record.level !== undefined) ? (record.level || 0) : 0;
19900
19901
  const indent = indentLevel * indentSize;
19901
19902
  // Draw parent row
19902
19903
  this.drawDataRow(pdf, record, leafColumns, rowDimensionFields, margin, yPosition, columnWidth, rowHeight, indent, options, allColumns, isPivotGrid, rowDimensionColumnsByLevel, i, rowDimensionHeaders);
@@ -19904,24 +19905,17 @@ class IgxPdfExporterService extends IgxBaseExporter {
19904
19905
  // For hierarchical grids, check if this record has child records
19905
19906
  if (recordIsHierarchicalGrid) {
19906
19907
  const allDescendants = [];
19907
- // Collect all descendant records (children, grandchildren, etc.) that belong to this parent
19908
- // Child records have a different owner (island object) than the parent
19909
19908
  let j = i + 1;
19910
19909
  while (j < data.length && data[j].level > record.level) {
19911
- // Include all descendants (any level deeper)
19912
19910
  if (!data[j].hidden) {
19913
- allDescendants.push(data[j]);
19911
+ // Attach the original index into data
19912
+ allDescendants.push({ ...data[j], __index: j });
19914
19913
  }
19915
19914
  j++;
19916
19915
  }
19917
- // If there are descendant records, draw child table(s)
19918
19916
  if (allDescendants.length > 0) {
19919
- // Group descendants by owner to separate different child grids
19920
- // Owner is the actual island object, not a string
19921
- // Only collect DIRECT children (one level deeper) for initial grouping
19922
19917
  const directDescendantsByOwner = new Map();
19923
19918
  for (const desc of allDescendants) {
19924
- // Only include records that are exactly one level deeper (direct children)
19925
19919
  if (desc.level === record.level + 1) {
19926
19920
  const owner = desc.owner;
19927
19921
  if (!directDescendantsByOwner.has(owner)) {
@@ -19930,12 +19924,11 @@ class IgxPdfExporterService extends IgxBaseExporter {
19930
19924
  directDescendantsByOwner.get(owner).push(desc);
19931
19925
  }
19932
19926
  }
19933
- // Draw each child grid separately with its direct children only
19934
19927
  for (const [owner, directChildren] of directDescendantsByOwner) {
19935
- yPosition = this.drawHierarchicalChildren(pdf, data, allDescendants, // Pass all descendants so grandchildren can be found
19936
- directChildren, owner, yPosition, margin, childTableIndent, usableWidth, pageHeight, headerHeight, rowHeight, options);
19928
+ yPosition = this.drawHierarchicalChildren(pdf, data, allDescendants, // descendants WITH __index
19929
+ directChildren, // direct children WITH __index
19930
+ owner, yPosition, margin, childTableIndent, usableWidth, pageHeight, headerHeight, rowHeight, options);
19937
19931
  }
19938
- // Skip the descendant records we just processed
19939
19932
  i = j - 1;
19940
19933
  }
19941
19934
  }
@@ -20200,29 +20193,42 @@ class IgxPdfExporterService extends IgxBaseExporter {
20200
20193
  // Draw the child record
20201
20194
  this.drawDataRow(pdf, childRecord, childColumns, [], childTableX, yPosition, childColumnWidth, rowHeight, 0, options);
20202
20195
  yPosition += rowHeight;
20203
- // Check if this child has grandchildren (deeper levels in different child grids)
20204
- // Look for grandchildren in allDescendants that are direct descendants of this childRecord
20205
- const grandchildrenForThisRecord = allDescendants.filter(r => r.level === childRecord.level + 1 && r.type !== 'HeaderRecord');
20206
- if (grandchildrenForThisRecord.length > 0) {
20207
- // Group grandchildren by their owner (different child islands under this record)
20208
- const grandchildrenByOwner = new Map();
20209
- for (const gc of grandchildrenForThisRecord) {
20210
- // Use the actual owner object
20211
- const gcOwner = gc.owner;
20212
- // Only include grandchildren that have a different owner (separate child grid)
20213
- if (gcOwner !== childOwner) {
20214
- if (!grandchildrenByOwner.has(gcOwner)) {
20215
- grandchildrenByOwner.set(gcOwner, []);
20196
+ // allDescendants here is an array of records with an extra __index property
20197
+ const childIndex = childRecord.__index;
20198
+ if (childIndex !== undefined) {
20199
+ // Find this child's position in allDescendants (by original index)
20200
+ const childPosInDesc = allDescendants.findIndex(d => d.__index === childIndex);
20201
+ if (childPosInDesc !== -1) {
20202
+ const subtree = [];
20203
+ const childLevel = childRecord.level;
20204
+ // Collect all deeper records until we hit same-or-higher level
20205
+ for (let k = childPosInDesc + 1; k < allDescendants.length; k++) {
20206
+ const rec = allDescendants[k];
20207
+ if (rec.level <= childLevel) {
20208
+ break;
20209
+ }
20210
+ if (rec.type !== 'HeaderRecord') {
20211
+ subtree.push(rec);
20212
+ }
20213
+ }
20214
+ if (subtree.length > 0) {
20215
+ // Direct grandchildren for this child: exactly one level deeper
20216
+ const grandchildrenForThisRecord = subtree.filter(r => r.level === childRecord.level + 1 && r.owner !== childOwner);
20217
+ if (grandchildrenForThisRecord.length > 0) {
20218
+ const grandchildrenByOwner = new Map();
20219
+ for (const gc of grandchildrenForThisRecord) {
20220
+ const gcOwner = gc.owner;
20221
+ if (!grandchildrenByOwner.has(gcOwner)) {
20222
+ grandchildrenByOwner.set(gcOwner, []);
20223
+ }
20224
+ grandchildrenByOwner.get(gcOwner).push(gc);
20225
+ }
20226
+ for (const [gcOwner, directGrandchildren] of grandchildrenByOwner) {
20227
+ yPosition = this.drawHierarchicalChildren(pdf, allData, subtree, // only this child's subtree for deeper levels
20228
+ directGrandchildren, gcOwner, yPosition, margin, indentPerLevel + 20, usableWidth, pageHeight, headerHeight, rowHeight, options);
20229
+ }
20216
20230
  }
20217
- grandchildrenByOwner.get(gcOwner).push(gc);
20218
20231
  }
20219
- }
20220
- // Recursively draw each grandchild owner's records with increased indentation
20221
- for (const [gcOwner, directGrandchildren] of grandchildrenByOwner) {
20222
- yPosition = this.drawHierarchicalChildren(pdf, allData, allDescendants, // Pass all descendants so great-grandchildren can be found
20223
- directGrandchildren, // Direct grandchildren to render
20224
- gcOwner, yPosition, margin, indentPerLevel + 20, // Increase indentation for next level
20225
- usableWidth, pageHeight, headerHeight, rowHeight, options);
20226
20232
  }
20227
20233
  }
20228
20234
  }