ngautocomplete devextreme is lagging to show dropdown and sometimes not load

16 Views Asked by At

Devexteme ngautocomplete is lagging and drop down is not showing after api call everytime search is performed Below is code

<dx-autocomplete #autocompleteRef [dataSource]="employeesIAM" valueExpr="login" [grouped]="false" [searchExpr]="['login','firstName','lastName']"
        label="Enter login or name" labelMode="floating" [showClearButton]="true" [minSearchLength]="3"
        (onSelectionChanged)="onSelectionChanged($event);"  groupTemplate="group"
        (onValueChanged)="search($event)" 
        itemTemplate="item" [wrapItemText]="true" [searchTimeout]="300" >
        </dx-autocomplete>
this.searchTerms.pipe(
      debounceTime(1000),
      distinctUntilChanged(),
      switchMap((query:string)=> this._crewService.getEmployeeList(query))
    ).subscribe(res => {
      this.employeesIAM = [];
      this.employeesIAM = res;
      this.employeesIAM.map(abc => abc.login = `${abc.login}  ${abc.firstName} ${abc.lastName}`);
      this.employeesIAM.map(abc => abc.Name = `${abc.firstName} ${abc.lastName}`);
    });

onValueChanged(data: any) {
    if (data != null && data.length >= 3) {
      this._crewService.getEmployeeList(data).subscribe(res => {
        this.employeesIAM = [];
        this.employeesIAM = res;
        this.employeesIAM.map(abc => abc.loginAndName = `${abc.login}  ${abc.firstName} ${abc.lastName}`);
        this.employeesIAM.map(abc => abc.Name = `${abc.firstName} ${abc.lastName}`);
      });
    }
  }

Can you suggest to prevent this lagging

0

There are 0 best solutions below