Hi,
I'm trying to implement a form for dialog Add/Edit. I have two controls, one autocomplete and one dropdown. They both use external source to get the data.
Controls are used as this:
<ejs-autocomplete id='propOne' name="propOne" #propOne [(ngModel)]="entityData.propOne"
[dataSource]='propOneData | async' [fields]="{ value: 'name' }" [placeholder]="'Select a propOne'"
[minLength]="minLength" (filtering)="onFilteringPropOne($event, propOne)" (select)="onSelectPropOne($event)">
ejs-autocomplete>
and dropdown list as:
<ejs-dropdownlist id="propTwo" name="propTwo" #propTwo[(ngModel)]="entityData.propTwo"
[allowFiltering]='true' (filtering)="onFilteringPropTwo($event, propTwo)"
[dataSource]='propTwoData | async' [fields]="{text: 'fullName', value: 'fullName' }"
placeholder="propTwo" popupHeight='300px' floatLabelType='Always'>ejs-dropdownlist>
And code behind:
public onFilteringPropOne: EmitType<FilteringEventArgs> = (e: FilteringEventArgs, remote: AutoCompleteComponent) => {
if (e.text.length >= 2) {
this.propOneData = this.getPropOneData(remote, e.text);
e.preventDefaultAction = true;
} else {
e.cancel = true;
}
}
public getPropOneData(remote: AutoCompleteComponent, text: string): Observable<PropOne[]> {
return this.propOneService.getPropOneAutcomplete(text)
.pipe(map((remoteData: PropOne[]) => {
remote.hidePopup();
setTimeout(() => remote.showPopup(), 500);
return remoteData;
}));
}
public onFilteringPropTwo: EmitType<FilteringEventArgs> = (e: FilteringEventArgs, remote: DropDownListComponent) => {
if (e.text.length >= 2) {
this.propTwoData = this.getPropTwoData(remote, e.text);
e.preventDefaultAction = true;
} else {
e.cancel = true;
}
}
public getPropTwoData(remote: DropDownListComponent, text: string): Observable<PropTwoAutoComplete[]> {
return this.propTwoService.getPropTwoAutoComplete(text)
.pipe(map((remoteData: PropTwoAutoComplete[]) => {
return remoteData;
}));
}
The first problem I have: it works when I add one new row to the Grid. But when I try to edit that row, only autocomplete field is populated. Dropdown field stays empty.
The second problem is, that when I open the dialog for the second time (for add or edit) I get this error in console:
ERROR TypeError: Cannot read property 'getBoundingClientRect' of null
at AutoCompleteComponent. (drop-down-list.js:1568) at AutoCompleteComponent.push../node_modules/@syncfusion/ej2-angular-base/src/component-base.js.ComponentBase.trigger (component-base.js:256)
at AutoCompleteComponent.push../node_modules/@syncfusion/ej2-dropdowns/src/drop-down-list/drop-down-list.js.DropDownList.renderPopup (drop-down-list.js:1545)
at AutoCompleteComponent.push../node_modules/@syncfusion/ej2-dropdowns/src/auto-complete/auto-complete.js.AutoComplete.renderPopup (auto-complete.js:237)
at AutoCompleteComponent.push../node_modules/@syncfusion/ej2-dropdowns/src/drop-down-list/drop-down-list.js.DropDownList.onActionComplete (drop-down-list.js:1487)
at AutoCompleteComponent.push../node_modules/@syncfusion/ej2-dropdowns/src/combo-box/combo-box.js.ComboBox.onActionComplete (combo-box.js:212)
at AutoCompleteComponent.push../node_modules/@syncfusion/ej2-dropdowns/src/auto-complete/auto-complete.js.AutoComplete.onActionComplete (auto-complete.js:171)
at AutoCompleteComponent. (drop-down-base.js:477) at AutoCompleteComponent.push../node_modules/@syncfusion/ej2-angular-base/src/component-base.js.ComponentBase.trigger (component-base.js:256)
at AutoCompleteComponent. (drop-down-base.js:474) It seems like there is a connection left between this component when I open this component.
I need to use this approach of fetching data from the server, because the sources for both autocomplete and dropdown are simply too big.