Not Binding Datasource during first dropdown

I have these XAML declaration
<autocomplete:SfAutoComplete 
                                    x:Name="autocomplete" 
                                    MinimumPrefixCharacters="3"
                                    AutoCompleteMode="Suggest"
                                    HeightRequest="40" 
                                    DropDownItemHeight="30" 
                                    Text="{Binding Text, Mode=TwoWay}"
                                    DataSource="{Binding BarangayList}"
                        MaximumDropDownHeight="200"
                                    ShowSuggestionsOnFocus="true"
                                    NoResultsFoundText="No Results" 
                                    SelectedValuePath="ID"
                                    IsDropDownOpen="{Binding IsDropDownOpen,Mode=TwoWay}"
                                    DropDownFooterViewHeight="{Binding DropDownFooterViewHeight,Mode=TwoWay}"
                                    DisplayMemberPath="DESCRIPTION"
                                    SelectedValue="{Binding BARANGAY_INDEXER, Mode=TwoWay}">
                                    <autocomplete:SfAutoComplete.DropDownFooterView>
                                        <Grid VerticalOptions="StartAndExpand" 
                                              HeightRequest="60"  
                                              BackgroundColor="#f0f0f0">
                                            <busyindicator:SfBusyIndicator x:Name="busyindicator" 
                                                    VerticalOptions="Start"
                                                    AnimationType="SlicedCircle" 
                                                    ViewBoxWidth = "40" 
                                                    ViewBoxHeight="40" 
                                                    TextColor="Maroon" 
                                                    IsBusy="{Binding IsBusy,Mode=TwoWay}" />
                                        </Grid>
                                    </autocomplete:SfAutoComplete.DropDownFooterView>
                                </autocomplete:SfAutoComplete>
                               
And here is the model 
 private ObservableCollection<Classes.BarangayCityModel> _BarangayList = new ObservableCollection<BarangayCityModel>();
        public ObservableCollection<Classes.BarangayCityModel> BarangayList
        {
            get
            {
                return _BarangayList;
            }
            set
            {
                _BarangayList = value;
                OnPropertyChanged("BarangayList");
            }
        }

        private string text = "";
        public string Text {
            get { return text; }
            set
            {
                text = value;
                OnPropertyChanged("Text");
                if (!string.IsNullOrEmpty(text) && text.Length==3)
                {
                    GetData(text);
                }
            } 
        }
        
        private bool isbusy;

        public bool IsBusy
        {
            get { return isbusy; }
            set { isbusy = value;
                OnPropertyChanged("IsBusy");
            }
        }
        private int dropdownfooterviewheight=60;

        public int DropDownFooterViewHeight
        {
            get { return dropdownfooterviewheight; }
            set { dropdownfooterviewheight = value;
                OnPropertyChanged("DropDownFooterViewHeight");
            }
        }

        async void GetData(string text)
        {
            string URL = Globals.URL + string.Format("Barangay/GetListFilter/{0}", text);
            IsBusy = true;
            var client = new HttpClient();
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Globals.token.access_token);
            var content = await client.GetStringAsync(URL);
            var list = JsonConvert.DeserializeObject<List<Classes.BarangayCityModel>>(content);
            BarangayList = new ObservableCollection<BarangayCityModel>(list);
            IsBusy = false;
            DropDownFooterViewHeight = 0;
            IsDropDownOpen = false;
        }

The issue here is that during the first time I typed something on the autocomplete control, it will automatically say "No Results", but when I closed the dropdown of autocomplete, and click again the autocomplete control, it will show all the result that was supposedly showing the first type I was typing.

What settings do I have to change? Or what code did I miss?

Thank you.

9 Replies 1 reply marked as answer

SS Suganya Sethuraman Syncfusion Team October 19, 2020 08:20 AM UTC

Hi Martin,

Greetings from Syncfusion.

We have tried to replicate the reported issue at our end, we are afraid that we are not able to reproduce the issue at our end. We have attached sample for your reference.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/JSONListUsage-1447851344-437989426

Since we are not aware of your exact application scenario, we were not able to reproduce this issue at our end, so can you please provide complete runnable sample. This will be helpful for us to investigate further and provide you a better solution at the earliest.

Regards,
Suganya Sethuraman.  
 



MS Martin Sato October 20, 2020 02:11 AM UTC

Hi,

  If you can see, your example loads the whole list upon loading of the page/form, my example, will only load what the user first few characters typed,
 
  let say, user will type "gui" as a start for search, then my model will request data from server to load anything that starts/contains "gui" and assigned it to the datasource, as for current behavior, the first time I typed something, it will not display but "no result", but when I close the popup from autocomplete control, and subsequently tap the autocomplete control, it displays all the data requested from server.

 I have no problem with list/source loaded ahead of time, my issue is when the user type something, and data is returned, it is not directly bound to the datasource, I have to close/dismiss the popup of autocomplete and when I tap again, there the list is shown.

To summarize

   1. On load, autocomplete datasource is empty/null
   2. User will type something, my model is triggered to fetch data from remote service
   3. Data is returned and trigger changeevent to infom autocomplete control of the changes
   4. Autocomplete control displays "no result"
   5. I have to close the popup displayed by sfautocomplete
   6. Since i set to show popup upon tap, it now displays the data matched from #2
   
I hope my statement is clear.

Thank you.


SS Suganya Sethuraman Syncfusion Team October 20, 2020 02:08 PM UTC

Hi Martin,

We are currently Validating on this with high priority and we will update the details on October 21st, 2020. We appreciate your patience until then.

Regards,
Suganya Sethuraman. 




MS Martin Sato October 20, 2020 02:44 PM UTC

Thank you for your prompt reply, I will be waiting.


SS Suganya Sethuraman Syncfusion Team October 21, 2020 02:28 PM UTC

Hi Martin,

We have tried to replicate the reported issue at our end, we are afraid that we are not able to reproduce the issue at our end. We have attached sample and for your reference.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/AutoCompleteWithMinPrefer-587337689

Video: https://www.syncfusion.com/downloads/support/directtrac/general/ze/AutoCompleteSearch.mov-1484165015

If you are still facing the same issue, please modify the sample with reported issue and reverts us. It will help us to provide better solution at the earliest.

Regards,
Suganya Sethuraman.   
 



MS Martin Sato October 22, 2020 02:47 AM UTC

Hi,

  I have tried your sample and it worked since the list is within the client already, but I am attaching a sample project to demonstrate the issue.

Type gui the sfautocomplete displays no result, but when you click the close (x) to dismiss popup, and tap again the sfautocomplete, it will show the data/list.



Thanks.

Attachment: AutoCompleteWithMinPrefer587337689updated_14ec21c0.rar


SS Suganya Sethuraman Syncfusion Team October 22, 2020 11:58 AM UTC

Hi Martin,

We have analyzed your requirement. We've met your requirement by setting SuggestionMode is Contains as a code snippet below.

Code snippet:
 
<autocomplete:SfAutoComplete 
            x:Name="autocomplete" 
            AutoCompleteMode="Suggest" 
            DataSource="{Binding BarangayList}" 
            DisplayMemberPath="DESCRIPTION" 
            DropDownFooterViewHeight="{Binding DropDownFooterViewHeight, Mode=TwoWay}" 
            DropDownItemHeight="30" 
            HeightRequest="45" 
            IsDropDownOpen="{Binding IsDropDownOpen, Mode=TwoWay}" 
            MaximumDropDownHeight="200" 
            MinimumPrefixCharacters="3" 
            NoResultsFoundText="No Results" 
            SelectedValue="{Binding BARANGAY_INDEXER, Mode=TwoWay}" 
            SelectedValuePath="ID" 
            ShowSuggestionsOnFocus="true" 
            SuggestionMode="Contains" 
            Text="{Binding Text, Mode=TwoWay}"> 
            <autocomplete:SfAutoComplete.DropDownFooterView> 
                <Grid 
                    BackgroundColor="#f0f0f0" 
                    HeightRequest="60" 
                    VerticalOptions="StartAndExpand"> 
                    <busyindicator:SfBusyIndicator 
                        x:Name="busyindicator" 
                        AnimationType="SlicedCircle" 
                        IsBusy="{Binding IsBusy, Mode=TwoWay}" 
                        TextColor="Maroon" 
                        VerticalOptions="Start" 
                        ViewBoxHeight="40" 
                        ViewBoxWidth="40" /> 
                </Grid> 
            </autocomplete:SfAutoComplete.DropDownFooterView> 
        </autocomplete:SfAutoComplete> 
 
Please have the modified sample,

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/AutoCompleteContains-1768000991

Please check the sample if it meets your requirements and let us know if you have any concerns.

Regards,
Suganya Sethuraman.


Marked as answer

MS Martin Sato October 22, 2020 02:55 PM UTC

It is working now, thank you very much.


SS Suganya Sethuraman Syncfusion Team October 23, 2020 05:19 AM UTC

Hi Martin,

Thanks for the update.

We are glad to know that the given solution works. Please let us know if you need any further assistance.

Regards,
Suganya Sethuraman.
 


Loader.
Up arrow icon