11import { HttpClient } from '@angular/common/http' ;
2- import { ChangeDetectorRef , Component , OnInit , ViewChild } from '@angular/core' ;
2+ import { AfterViewInit , ChangeDetectorRef , Component , OnInit , ViewChild } from '@angular/core' ;
33import { FilteringExpressionsTree , FilteringLogic , IExpressionTree , IgxColumnComponent , IgxGridComponent , IgxQueryBuilderComponent } from 'igniteui-angular' ;
44
55const API_ENDPOINT = 'https://data-northwind.indigo.design' ;
@@ -10,7 +10,7 @@ const API_ENDPOINT = 'https://data-northwind.indigo.design';
1010 templateUrl : 'query-builder-request-sample.component.html' ,
1111 imports : [ IgxQueryBuilderComponent , IgxGridComponent , IgxColumnComponent ]
1212} )
13- export class QueryBuilderRequestSampleComponent implements OnInit {
13+ export class QueryBuilderRequestSampleComponent implements OnInit , AfterViewInit {
1414 @ViewChild ( 'grid' , { static : true } )
1515 public grid : IgxGridComponent ;
1616
@@ -56,18 +56,21 @@ export class QueryBuilderRequestSampleComponent implements OnInit {
5656
5757 const tree = new FilteringExpressionsTree ( FilteringLogic . And , undefined , 'Orders' , [ 'orderId' , 'customerId' , 'employeeId' , 'shipperId' , 'orderDate' , 'requiredDate' , 'shipVia' , 'freight' , 'shipName' , 'completed' ] ) ;
5858 this . expressionTree = tree ;
59-
59+ }
60+
61+ public ngAfterViewInit ( ) : void {
6062 this . onChange ( ) ;
6163 }
6264
65+
6366 public onChange ( ) {
6467 this . grid . isLoading = true ;
6568 this . http . post ( `${ API_ENDPOINT } /QueryBuilder/ExecuteQuery` , this . expressionTree ) . subscribe ( data => {
6669 this . data = Object . values ( data ) [ 0 ] ;
6770 this . grid . isLoading = false ;
71+ this . cdr . detectChanges ( ) ;
72+ this . calculateColsInView ( ) ;
6873 } ) ;
69- this . cdr . detectChanges ( ) ;
70- this . calculateColsInView ( ) ;
7174 }
7275
7376 private calculateColsInView ( ) {
0 commit comments