@@ -29,7 +29,6 @@ import { IgxFilteringService } from '../filtering/grid-filtering.service';
2929import { IgxGridSelectionService } from '../selection/selection.service' ;
3030import { IgxForOfSyncService , IgxForOfScrollSyncService } from '../../directives/for-of/for_of.sync.service' ;
3131import { GridType } from '../common/grid.interface' ;
32- import { IgxGridNavigationService } from '../grid-navigation.service' ;
3332import { IgxGridCRUDService } from '../common/crud.service' ;
3433import { IgxGridSummaryService } from '../summaries/grid-summary.service' ;
3534import { IPivotConfiguration , IPivotDimension , IPivotKeys , PivotDimensionType } from './pivot-grid.interface' ;
@@ -263,14 +262,9 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
263262
264263 public columnGroupStates = new Map < string , boolean > ( ) ;
265264 public dimensionDataColumns ;
266- public pivotKeys : IPivotKeys = { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' } ;
265+ public pivotKeys : IPivotKeys = { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' } ;
267266 public isPivot = true ;
268267
269- /**
270- * @hidden @internal
271- */
272- public selectedPivotKeys = new Map < string , any [ ] > ( ) ;
273-
274268 /**
275269 * @hidden @internal
276270 */
@@ -407,13 +401,23 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
407401 }
408402
409403 public get selectedRows ( ) : any [ ] {
410- const selectedRowKeys = this . selectionService . getSelectedRows ( ) ;
404+ if ( ! this . selectionService . getSelectedRows ( ) ) {
405+ return [ ] ;
406+ }
411407 const selectedRowIds = [ ] ;
412- this . selectedPivotKeys . forEach ( ( value , key ) => {
413- if ( selectedRowKeys . find ( x => key . includes ( x ) ) && ! selectedRowIds . find ( x => x === value ) ) {
414- selectedRowIds . push ( value ) ;
408+ this . dataView . forEach ( record => {
409+ const prev = [ ] ;
410+ for ( const dim of this . rowDimensions ) {
411+ const key = PivotUtil . getRecordKey ( record , dim , prev ) ;
412+ prev . push ( dim ) ;
413+ if ( this . selectionService . isPivotRowSelected ( key ) && ! selectedRowIds . find ( x => x === record ) ) {
414+ selectedRowIds . push ( record ) ;
415+ break ;
416+ }
415417 }
418+
416419 } ) ;
420+
417421 return selectedRowIds ;
418422 }
419423
@@ -497,24 +501,24 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
497501 public getDimensionData ( dim : IPivotDimension ,
498502 dimExprTree : IFilteringExpressionsTree ,
499503 done : ( colVals : any [ ] ) => void ) {
500- let columnValues = [ ] ;
501- const data = this . gridAPI . get_data ( ) ;
502- const state = {
503- expressionsTree : dimExprTree ,
504- strategy : this . filterStrategy || new DimensionValuesFilteringStrategy ( ) ,
505- advancedFilteringExpressionsTree : this . advancedFilteringExpressionsTree
506- } ;
507- const filtered = DataUtil . filter ( data , state , this ) ;
508- const allValuesHierarchy = PivotUtil . getFieldsHierarchy (
509- filtered ,
510- [ dim ] ,
511- PivotDimensionType . Column ,
512- { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
513- ) ;
514- const flatData = Array . from ( allValuesHierarchy . values ( ) ) ;
515- columnValues = flatData . map ( record => this . extractValue ( record [ 'value' ] ) ) ;
516- done ( columnValues ) ;
517- return ;
504+ let columnValues = [ ] ;
505+ const data = this . gridAPI . get_data ( ) ;
506+ const state = {
507+ expressionsTree : dimExprTree ,
508+ strategy : this . filterStrategy || new DimensionValuesFilteringStrategy ( ) ,
509+ advancedFilteringExpressionsTree : this . advancedFilteringExpressionsTree
510+ } ;
511+ const filtered = DataUtil . filter ( data , state , this ) ;
512+ const allValuesHierarchy = PivotUtil . getFieldsHierarchy (
513+ filtered ,
514+ [ dim ] ,
515+ PivotDimensionType . Column ,
516+ { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
517+ ) ;
518+ const flatData = Array . from ( allValuesHierarchy . values ( ) ) ;
519+ columnValues = flatData . map ( record => this . extractValue ( record [ 'value' ] ) ) ;
520+ done ( columnValues ) ;
521+ return ;
518522 }
519523
520524 /** @hidden */
@@ -906,12 +910,12 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
906910 /**
907911 * @hidden
908912 */
909- protected autogenerateColumns ( ) {
910- let columns = [ ] ;
911- const data = this . gridAPI . get_data ( ) ;
912- this . dimensionDataColumns = this . generateDimensionColumns ( ) ;
913- let fieldsMap ;
914- if ( this . pivotConfiguration . columnStrategy && this . pivotConfiguration . columnStrategy instanceof NoopPivotDimensionsStrategy ) {
913+ protected autogenerateColumns ( ) {
914+ let columns = [ ] ;
915+ const data = this . gridAPI . get_data ( ) ;
916+ this . dimensionDataColumns = this . generateDimensionColumns ( ) ;
917+ let fieldsMap ;
918+ if ( this . pivotConfiguration . columnStrategy && this . pivotConfiguration . columnStrategy instanceof NoopPivotDimensionsStrategy ) {
915919 const fields = this . generateDataFields ( data ) ;
916920 const rowFields = PivotUtil . flatten ( this . pivotConfiguration . rows ) . map ( x => x . memberName ) ;
917921 const keyFields = Object . values ( this . pivotKeys ) ;
@@ -1003,7 +1007,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
10031007 columns = columns . concat ( measureChildren ) ;
10041008 }
10051009
1006- } else if ( shouldGenerate ) {
1010+ } else if ( shouldGenerate ) {
10071011 const ref = factoryColumnGroup . create ( this . viewRef . injector ) ;
10081012 ref . instance . parent = parent ;
10091013 ref . instance . field = key ;
0 commit comments