@@ -54,6 +54,8 @@ export interface IColumnInfo {
54
54
level ?: number ;
55
55
exportIndex ?: number ;
56
56
pinnedIndex ?: number ;
57
+ columnGroupParent ?: ColumnType ;
58
+ columnGroup ?: ColumnType ;
57
59
}
58
60
/**
59
61
* rowExporting event arguments
@@ -307,8 +309,18 @@ export abstract class IgxBaseExporter {
307
309
shouldReorderColumns = true ;
308
310
}
309
311
310
- if ( column . skip && index <= indexOfLastPinnedColumn ) {
311
- skippedPinnedColumnsCount ++ ;
312
+ if ( column . skip ) {
313
+ if ( index <= indexOfLastPinnedColumn ) {
314
+ skippedPinnedColumnsCount ++ ;
315
+ }
316
+
317
+ this . calculateColumnSpans ( column , mapRecord , column . columnSpan ) ;
318
+
319
+ const nonSkippedColumns = mapRecord . columns . filter ( c => ! c . skip ) ;
320
+
321
+ if ( nonSkippedColumns . length > 0 ) {
322
+ this . _ownersMap . get ( key ) . maxLevel = nonSkippedColumns . sort ( ( a , b ) => b . level - a . level ) [ 0 ] . level ;
323
+ }
312
324
}
313
325
314
326
if ( this . _sort && this . _sort . fieldName === column . field ) {
@@ -344,35 +356,72 @@ export abstract class IgxBaseExporter {
344
356
} ) ;
345
357
}
346
358
359
+ private calculateColumnSpans ( column : IColumnInfo , mapRecord : IColumnList , span : number ) {
360
+ if ( column . headerType === HeaderType . MultiColumnHeader && column . skip ) {
361
+ const columnGroupChildren = mapRecord . columns . filter ( c => c . columnGroupParent === column . columnGroup ) ;
362
+
363
+ columnGroupChildren . forEach ( cgc => {
364
+ if ( cgc . headerType === HeaderType . MultiColumnHeader ) {
365
+ cgc . columnSpan = 0 ;
366
+ cgc . columnGroupParent = null ;
367
+ cgc . skip = true ;
368
+
369
+ this . calculateColumnSpans ( cgc , mapRecord , cgc . columnSpan ) ;
370
+ } else {
371
+ cgc . skip = true ;
372
+ }
373
+ } ) ;
374
+ }
375
+
376
+ const targetCol = mapRecord . columns . filter ( c => column . columnGroupParent !== null && c . columnGroup === column . columnGroupParent ) [ 0 ] ;
377
+ if ( targetCol !== undefined ) {
378
+ targetCol . columnSpan -= span ;
379
+
380
+ if ( targetCol . columnGroupParent !== null ) {
381
+ this . calculateColumnSpans ( targetCol , mapRecord , span ) ;
382
+ }
383
+
384
+ if ( targetCol . columnSpan === 0 ) {
385
+ targetCol . skip = true ;
386
+ }
387
+ }
388
+ }
389
+
347
390
private exportRow ( data : IExportRecord [ ] , record : IExportRecord , index : number , isSpecialData : boolean ) {
348
- if ( ! isSpecialData && record . type !== ExportRecordType . HeaderRecord ) {
391
+ if ( ! isSpecialData ) {
349
392
const owner = record . owner === undefined ? DEFAULT_OWNER : record . owner ;
393
+ const ownerCols = this . _ownersMap . get ( owner ) . columns ;
394
+
395
+ if ( record . type !== ExportRecordType . HeaderRecord ) {
396
+ const columns = ownerCols
397
+ . filter ( c => c . headerType !== HeaderType . MultiColumnHeader && ! c . skip )
398
+ . sort ( ( a , b ) => a . startIndex - b . startIndex )
399
+ . sort ( ( a , b ) => a . pinnedIndex - b . pinnedIndex ) ;
400
+
401
+ record . data = columns . reduce ( ( a , e ) => {
402
+ if ( ! e . skip ) {
403
+ let rawValue = resolveNestedPath ( record . data , e . field ) ;
404
+
405
+ const shouldApplyFormatter = e . formatter && ! e . skipFormatter && record . type !== ExportRecordType . GroupedRecord ;
406
+
407
+ if ( e . dataType === 'date' &&
408
+ ! ( rawValue instanceof Date ) &&
409
+ ! shouldApplyFormatter &&
410
+ rawValue !== undefined &&
411
+ rawValue !== null ) {
412
+ rawValue = new Date ( rawValue ) ;
413
+ } else if ( e . dataType === 'string' && rawValue instanceof Date ) {
414
+ rawValue = rawValue . toString ( ) ;
415
+ }
350
416
351
- const columns = this . _ownersMap . get ( owner ) . columns
352
- . filter ( c => c . headerType !== HeaderType . MultiColumnHeader )
353
- . sort ( ( a , b ) => a . startIndex - b . startIndex )
354
- . sort ( ( a , b ) => a . pinnedIndex - b . pinnedIndex ) ;
355
-
356
- record . data = columns . reduce ( ( a , e ) => {
357
- if ( ! e . skip ) {
358
- let rawValue = resolveNestedPath ( record . data , e . field ) ;
359
-
360
- const shouldApplyFormatter = e . formatter && ! e . skipFormatter && record . type !== ExportRecordType . GroupedRecord ;
361
-
362
- if ( e . dataType === 'date' &&
363
- ! ( rawValue instanceof Date ) &&
364
- ! shouldApplyFormatter &&
365
- rawValue !== undefined &&
366
- rawValue !== null ) {
367
- rawValue = new Date ( rawValue ) ;
368
- } else if ( e . dataType === 'string' && rawValue instanceof Date ) {
369
- rawValue = rawValue . toString ( ) ;
417
+ a [ e . field ] = shouldApplyFormatter ? e . formatter ( rawValue ) : rawValue ;
370
418
}
371
-
372
- a [ e . field ] = shouldApplyFormatter ? e . formatter ( rawValue ) : rawValue ;
373
- }
374
- return a ;
375
- } , { } ) ;
419
+ return a ;
420
+ } , { } ) ;
421
+ } else {
422
+ const filteredHeaders = ownerCols . filter ( c => c . skip ) . map ( c => c . header ? c . header : c . field ) ;
423
+ record . data = record . data . filter ( d => filteredHeaders . indexOf ( d ) === - 1 ) ;
424
+ }
376
425
}
377
426
378
427
const rowArgs = {
@@ -860,7 +909,9 @@ export abstract class IgxBaseExporter {
860
909
Number . MAX_VALUE :
861
910
! column . hidden ?
862
911
column . grid . pinnedColumns . indexOf ( column )
863
- : NaN
912
+ : NaN ,
913
+ columnGroupParent : column . parent ? column . parent : null ,
914
+ columnGroup : isMultiColHeader ? column : null
864
915
} ;
865
916
866
917
if ( this . options . ignoreColumnsOrder ) {
0 commit comments