We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to update the data source, after calling external API using filtering event of autocomplete

Hi,

Problem:The data source(autoCompData) is not updating which is attached to autocomplete control ,after calling an external api call on event of filtering and updating data as below.
html:
4
ts:


But the data-source is not updated with remote filtered data.

Why this:When drop down button is clicked ,showing no records,But on filtering showing pop up with data.

Thank you.

5 Replies

PO Prince Oliver Syncfusion Team July 17, 2019 12:58 PM UTC

Hi Goutham 

Thank you for contacting us. 

We checked the share code snippet. It seems that you have initialized the dataSource as empty array([]) and then have assigned the some results to dataSource property in the filtering event. Hence during the initialization, when you click dropdown button the result is empty. The filtering event will trigger only when you start typing the characters in the input. So we suggest you assign the below code to actoComData at the initialization. 
 
public actoComData = this.SomeService.getFiltered(''); 
 
Let us know if you need any further assistance on this. 

Regards, 
Prince 



GO Goutham July 17, 2019 03:21 PM UTC

Hi,

But until i  search something ,no records are found that is ok at initial stage.After search i have records from result of API call.i am using event.updateData() method to update records,so that pop up opens and shows updated records,once i close popup and open it again with drop down click there is no records to show.

requirement:can i  load the records into autoCompData(which is initialized to dataSource of auto complete) after API call.i tried this way but not working.


PO Prince Oliver Syncfusion Team July 19, 2019 04:32 AM UTC

Hi Goutham, 

Thank you for your update. 

We checked the reported scenario. To show the data again when you click the popup button, we suggest you set the result back to the autoCompData in the beforeOpen event. Please find the code snippet below, 

[app.component.ts] 
public onBeforeOpen(e) { 
    this.autoCompData = this.result; 
} 

[app.component.html] 
<ejs-autocomplete id='games' #sample [dataSource]='autoCompData' 
[placeholder]='waterMark' [fields]='fields'  (filtering)='onFiltering($event)' [showPopupButton] ="true" (beforeOpen)='onBeforeOpen($event)'></ejs-autocomplete> 



Let us know if you need any further assistance on this. 

Regards, 
Prince 



GO Goutham July 19, 2019 09:37 AM UTC

Thank you,its working as expected.


NP Narayanasamy Panneer Selvam Syncfusion Team July 22, 2019 10:17 AM UTC

Hi Goutham, 
 
Most welcome. we are glad that the issue is resolved in your end. 
 
Regards, 
Narayanasamy P. 


Loader.
Live Chat Icon For mobile
Up arrow icon