@@ -99,35 +99,7 @@ export class IgxAdvancedFilteringDialogComponent {
99
99
}
100
100
101
101
public addAndGroup ( parent ?: ExpressionGroupItem , afterExpression ?: ExpressionItem ) {
102
- const tree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
103
- tree . filteringOperands . push ( {
104
- fieldName : 'ID' ,
105
- condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
106
- searchVal : 'a' ,
107
- ignoreCase : true
108
- } ) ;
109
- const orTree = new FilteringExpressionsTree ( FilteringLogic . Or ) ;
110
- orTree . filteringOperands . push ( {
111
- fieldName : 'ID' ,
112
- condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
113
- searchVal : 'b' ,
114
- ignoreCase : true
115
- } ) ;
116
- orTree . filteringOperands . push ( {
117
- fieldName : 'CompanyName' ,
118
- condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
119
- searchVal : 'c' ,
120
- ignoreCase : true
121
- } ) ;
122
- tree . filteringOperands . push ( orTree ) ;
123
- tree . filteringOperands . push ( {
124
- fieldName : 'CompanyName' ,
125
- condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
126
- searchVal : 'd' ,
127
- ignoreCase : true
128
- } ) ;
129
- this . rootGroup = this . createExpressionGroupItem ( tree ) ;
130
- this . currentGroup = this . rootGroup ;
102
+ this . addGroup ( FilteringLogic . And , parent , afterExpression ) ;
131
103
}
132
104
133
105
public addOrGroup ( parent ?: ExpressionGroupItem , afterExpression ?: ExpressionItem ) {
@@ -181,7 +153,7 @@ export class IgxAdvancedFilteringDialogComponent {
181
153
this . currentGroup = groupItem ;
182
154
}
183
155
184
- private createExpressionGroupItem ( expressionTree : FilteringExpressionsTree , parent ?: ExpressionGroupItem ) : ExpressionGroupItem {
156
+ private createExpressionGroupItem ( expressionTree : IFilteringExpressionsTree , parent ?: ExpressionGroupItem ) : ExpressionGroupItem {
185
157
let groupItem : ExpressionGroupItem ;
186
158
if ( expressionTree ) {
187
159
groupItem = new ExpressionGroupItem ( expressionTree . operator , parent ) ;
@@ -199,6 +171,21 @@ export class IgxAdvancedFilteringDialogComponent {
199
171
return groupItem ;
200
172
}
201
173
174
+ private createExpressionsTreeFromGroupItem ( groupItem : ExpressionGroupItem ) : FilteringExpressionsTree {
175
+ const expressionsTree = new FilteringExpressionsTree ( groupItem . operator ) ;
176
+
177
+ for ( const item of groupItem . children ) {
178
+ if ( item instanceof ExpressionGroupItem ) {
179
+ const subTree = this . createExpressionsTreeFromGroupItem ( ( item as ExpressionGroupItem ) ) ;
180
+ expressionsTree . filteringOperands . push ( subTree ) ;
181
+ } else {
182
+ expressionsTree . filteringOperands . push ( ( item as ExpressionOperandItem ) . expression ) ;
183
+ }
184
+ }
185
+
186
+ return expressionsTree ;
187
+ }
188
+
202
189
public onChipRemove ( expressionItem : ExpressionItem ) {
203
190
this . deleteItem ( expressionItem ) ;
204
191
}
@@ -273,7 +260,41 @@ export class IgxAdvancedFilteringDialogComponent {
273
260
this . overlayService = overlayService ;
274
261
this . overlayComponentId = overlayComponentId ;
275
262
276
- // this.filteringExpressionsTree = this.grid.crossFieldFilteringExpressionsTree;
263
+ if ( ! this . grid . crossFieldFilteringExpressionsTree ) {
264
+ const tree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
265
+ tree . filteringOperands . push ( {
266
+ fieldName : 'ID' ,
267
+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
268
+ searchVal : 'a' ,
269
+ ignoreCase : true
270
+ } ) ;
271
+ const orTree = new FilteringExpressionsTree ( FilteringLogic . Or ) ;
272
+ orTree . filteringOperands . push ( {
273
+ fieldName : 'ID' ,
274
+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
275
+ searchVal : 'b' ,
276
+ ignoreCase : true
277
+ } ) ;
278
+ orTree . filteringOperands . push ( {
279
+ fieldName : 'CompanyName' ,
280
+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
281
+ searchVal : 'c' ,
282
+ ignoreCase : true
283
+ } ) ;
284
+ tree . filteringOperands . push ( orTree ) ;
285
+ tree . filteringOperands . push ( {
286
+ fieldName : 'CompanyName' ,
287
+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
288
+ searchVal : 'd' ,
289
+ ignoreCase : true
290
+ } ) ;
291
+ this . grid . crossFieldFilteringExpressionsTree = tree ;
292
+ }
293
+
294
+ if ( this . grid . crossFieldFilteringExpressionsTree ) {
295
+ this . rootGroup = this . createExpressionGroupItem ( this . grid . crossFieldFilteringExpressionsTree ) ;
296
+ this . currentGroup = this . rootGroup ;
297
+ }
277
298
}
278
299
279
300
public context ( expression : ExpressionItem , afterExpression ?: ExpressionItem ) {
@@ -295,7 +316,7 @@ export class IgxAdvancedFilteringDialogComponent {
295
316
}
296
317
297
318
public onApplyButtonClick ( ) {
298
- // this.grid.crossFieldFilteringExpressionsTree = this.filteringExpressionsTree ;
319
+ this . grid . crossFieldFilteringExpressionsTree = this . createExpressionsTreeFromGroupItem ( this . rootGroup ) ;
299
320
this . closeDialog ( ) ;
300
321
}
301
322
}
0 commit comments