@@ -1131,20 +1131,85 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
1131
1131
this . dimensionsChange . emit ( { dimensions : collection , dimensionCollectionType : dimType } ) ;
1132
1132
}
1133
1133
1134
+ /**
1135
+ * Inserts value at specified index or at the end.
1136
+ *
1137
+ * @example
1138
+ * ```typescript
1139
+ * this.grid.insertValueAt(value, 1);
1140
+ * ```
1141
+ * @param value The value definition that will be added.
1142
+ * @param index The index in the collection at which to add.
1143
+ * This parameter is optional. If not set it will add it to the end of the collection.
1144
+ */
1134
1145
public insertValueAt ( value : IPivotValue , index ?: number ) {
1135
-
1146
+ if ( ! this . pivotConfiguration . values ) {
1147
+ this . pivotConfiguration . values = [ ] ;
1148
+ }
1149
+ const values = this . pivotConfiguration . values ;
1150
+ if ( index !== undefined ) {
1151
+ values . splice ( index , 0 , value ) ;
1152
+ } else {
1153
+ values . push ( value ) ;
1154
+ }
1155
+ this . setupColumns ( ) ;
1156
+ this . pipeTrigger ++ ;
1157
+ this . valuesChange . emit ( { values } ) ;
1136
1158
}
1137
1159
1138
- public moveValue ( dimension : IPivotValue , index ?: number ) {
1139
-
1160
+ /**
1161
+ * Move value from its currently at specified index or at the end.
1162
+ *
1163
+ * @example
1164
+ * ```typescript
1165
+ * this.grid.moveValue(value, 1);
1166
+ * ```
1167
+ * @param value The value that will be moved.
1168
+ * @param index The index in the collection at which to add.
1169
+ * This parameter is optional. If not set it will add it to the end of the collection.
1170
+ */
1171
+ public moveValue ( value : IPivotValue , index ?: number ) {
1172
+ // remove from old index
1173
+ this . removeValue ( value ) ;
1174
+ // add to new
1175
+ this . insertValueAt ( value , index ) ;
1140
1176
}
1141
1177
1178
+ /**
1179
+ * Removes value from collection.
1180
+ * @remarks
1181
+ * This is different than toggleValue that enabled/disables the value.
1182
+ * This completely removes the specified value from the collection.
1183
+ * @example
1184
+ * ```typescript
1185
+ * this.grid.removeValue(dimension);
1186
+ * ```
1187
+ * @param value The value to be removed.
1188
+ */
1142
1189
public removeValue ( value : IPivotValue , ) {
1143
-
1190
+ const values = this . pivotConfiguration . values ;
1191
+ const currentIndex = values . indexOf ( value ) ;
1192
+ values . splice ( currentIndex , 1 ) ;
1193
+ this . setupColumns ( ) ;
1194
+ this . pipeTrigger ++ ;
1195
+ this . valuesChange . emit ( { values } ) ;
1144
1196
}
1145
1197
1198
+ /**
1199
+ * Toggles the value's enabled state on or off.
1200
+ * @remarks
1201
+ * The value remains in its current collection. This just changes its enabled state.
1202
+ * @example
1203
+ * ```typescript
1204
+ * this.grid.toggleValue(value);
1205
+ * ```
1206
+ * @param value The value to be toggled.
1207
+ */
1146
1208
public toggleValue ( value : IPivotValue ) {
1147
-
1209
+ value . enabled = ! value . enabled ;
1210
+ this . setupColumns ( ) ;
1211
+ this . pipeTrigger ++ ;
1212
+ this . valuesChange . emit ( { values : this . pivotConfiguration . values } ) ;
1148
1213
}
1149
1214
1150
1215
public getDimensionsByType ( dimension : PivotDimensionType ) {
0 commit comments