@@ -777,7 +777,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
777
777
}
778
778
779
779
public get values ( ) {
780
- return this . pivotConfiguration . values . filter ( x => x . enabled ) ;
780
+ return this . pivotConfiguration . values . filter ( x => x . enabled ) || [ ] ;
781
781
}
782
782
783
783
public toggleColumn ( col : IgxColumnComponent ) {
@@ -1076,6 +1076,9 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1076
1076
}
1077
1077
this . pipeTrigger ++ ;
1078
1078
this . dimensionsChange . emit ( { dimensions : targetCollection , dimensionCollectionType : targetCollectionType } ) ;
1079
+ if ( targetCollectionType === PivotDimensionType . Filter ) {
1080
+ this . reflow ( ) ;
1081
+ }
1079
1082
}
1080
1083
1081
1084
/**
@@ -1091,6 +1094,8 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1091
1094
* This parameter is optional. If not set it will add it to the end of the collection.
1092
1095
*/
1093
1096
public moveDimension ( dimension : IPivotDimension , targetCollectionType : PivotDimensionType , index ?: number ) {
1097
+ const prevCollectionType = this . getDimensionType ( dimension ) ;
1098
+ if ( prevCollectionType === null ) return ;
1094
1099
// remove from old collection
1095
1100
this . removeDimension ( dimension ) ;
1096
1101
// add to target
@@ -1110,6 +1115,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1110
1115
*/
1111
1116
public removeDimension ( dimension : IPivotDimension ) {
1112
1117
const prevCollectionType = this . getDimensionType ( dimension ) ;
1118
+ if ( prevCollectionType === null ) return ;
1113
1119
const prevCollection = this . getDimensionsByType ( prevCollectionType ) ;
1114
1120
const currentIndex = prevCollection . indexOf ( dimension ) ;
1115
1121
prevCollection . splice ( currentIndex , 1 ) ;
@@ -1134,6 +1140,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1134
1140
*/
1135
1141
public toggleDimension ( dimension : IPivotDimension ) {
1136
1142
const dimType = this . getDimensionType ( dimension ) ;
1143
+ if ( dimType === null ) return ;
1137
1144
const collection = this . getDimensionsByType ( dimType ) ;
1138
1145
dimension . enabled = ! dimension . enabled ;
1139
1146
if ( dimType === PivotDimensionType . Column ) {
@@ -1184,6 +1191,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1184
1191
* This parameter is optional. If not set it will add it to the end of the collection.
1185
1192
*/
1186
1193
public moveValue ( value : IPivotValue , index ?: number ) {
1194
+ if ( this . pivotConfiguration . values . indexOf ( value ) === - 1 ) return ;
1187
1195
// remove from old index
1188
1196
this . removeValue ( value ) ;
1189
1197
// add to new
@@ -1204,10 +1212,12 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1204
1212
public removeValue ( value : IPivotValue , ) {
1205
1213
const values = this . pivotConfiguration . values ;
1206
1214
const currentIndex = values . indexOf ( value ) ;
1207
- values . splice ( currentIndex , 1 ) ;
1208
- this . setupColumns ( ) ;
1209
- this . pipeTrigger ++ ;
1210
- this . valuesChange . emit ( { values } ) ;
1215
+ if ( currentIndex !== - 1 ) {
1216
+ values . splice ( currentIndex , 1 ) ;
1217
+ this . setupColumns ( ) ;
1218
+ this . pipeTrigger ++ ;
1219
+ this . valuesChange . emit ( { values } ) ;
1220
+ }
1211
1221
}
1212
1222
1213
1223
/**
@@ -1221,6 +1231,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1221
1231
* @param value The value to be toggled.
1222
1232
*/
1223
1233
public toggleValue ( value : IPivotValue ) {
1234
+ if ( this . pivotConfiguration . values . indexOf ( value ) === - 1 ) return ;
1224
1235
value . enabled = ! value . enabled ;
1225
1236
this . setupColumns ( ) ;
1226
1237
this . pipeTrigger ++ ;
@@ -1255,7 +1266,8 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1255
1266
1256
1267
protected getDimensionType ( dimension : IPivotDimension ) : PivotDimensionType {
1257
1268
return PivotUtil . flatten ( this . rowDimensions ) . indexOf ( dimension ) !== - 1 ? PivotDimensionType . Row :
1258
- PivotUtil . flatten ( this . columnDimensions ) . indexOf ( dimension ) !== - 1 ? PivotDimensionType . Column : PivotDimensionType . Filter ;
1269
+ PivotUtil . flatten ( this . columnDimensions ) . indexOf ( dimension ) !== - 1 ? PivotDimensionType . Column :
1270
+ PivotUtil . flatten ( this . columnDimensions ) . indexOf ( dimension ) !== - 1 ? PivotDimensionType . Filter : null ;
1259
1271
}
1260
1272
1261
1273
protected getLargesContentWidth ( contents : ElementRef [ ] ) : string {
0 commit comments