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

SfAutoComplete Without any List Filtering

Hello,

I would like to use SfAutoComplete. However, I do not need any autocompletion features. I would like to display a dropdown menu from an entry with items the user can click on. I shall provide the items from a list programtically. I.e. I would like to use SfAutoComplete without any list filtering. Is SfAutocomplete the best option for this?

EDIT: Can I dynamically change the DataSource programatically as the user types?

P.S. Just to confirm, can I use Sf objects as a sole proprietor for free?

Thanks!

18 Replies

MK Muneesh Kumar G Syncfusion Team August 14, 2019 05:36 AM UTC

Hi Max, 
  
Thanks for contacting Syncfusion support. 
  
We have checked your requirement in our side. You can use the SfComboBox control with AllowFiltering API as false. We have prepared a simple sample and please get form below link, 
  
  
If you don't need the DropDownIcon in SfComboBox control, use DropDownButtonSettings API to remove the button in SfComboBox control. 
  
Thanks,  
Muneesh Kumar G.  



MC Max Clark August 14, 2019 11:30 AM UTC

Great thanks!


MK Muneesh Kumar G Syncfusion Team August 14, 2019 11:47 AM UTC

Hi Max,  
 
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, 
Muneesh Kumar G 



MC Max Clark August 14, 2019 09:06 PM UTC

Hi Muneesh,

The SFComboBox is just what I need. I looked at the documentation for setting the ItemTemplate in XAML, here. What is the correct method for containing two variables in the item template, specific to each item? For example, each item has two Labels, displaying a person's name and age.

Considering this example, I tried binding the DataSource to ObservableCollection<DropDownItem> where DropDownItem is a class with one field: Person. And Person has fields Name and Age. I set the DisplayMemberPath to "Person" and then could bind the labels to Person.Name and Person.Age. However, the selected items were no longer of type Person.Name, but Person.

Is there a better method?


MK Muneesh Kumar G Syncfusion Team August 15, 2019 05:20 AM UTC

Hi Max,  
 
Thanks for the update. 
  
We have prepared the sample based on your requirement and please get the sample form below link, 
  
 
  
We have used the CustomView to show the text in the SfComboBox control in above sample.  
 
Please check and let us know if you need any other details. 
 
Thanks,   
Muneesh Kumar G.  
 



MC Max Clark August 15, 2019 02:39 PM UTC

Hi Muneesh,

The selection now works very well - thank you! However, it seems the user can no longer edit the text themselves, even if I set IsEditableMode="true". What is the fix for this?

Thanks,
Max


MC Max Clark August 16, 2019 12:04 PM UTC

Hi Muneesh,

I found a solution! Unfortunately, the CustomView solution did not work for me. I figured, you could replace the Label with an Entry, but there was no way to make it look nice on both platforms (without seeing a control inside a control) and the Entry.Text was not connected to the SfComboBox.Text.

The problem without using a CustomView is that setting comboBox.Text worked on Andriod, but not iOS, and it would display the type of object selected (whatever you set DisplayMemberPath to be). Instead, I discovered that you can set DisplayMemberPath to be a class, in which you override the ToString method to the desired field, and so you no longer need to set comboBox.Text.

Thank you for your help!


MC Max Clark August 16, 2019 12:55 PM UTC

Hello,

I have encountered a new problem. Calling .Clear() on the list binded to DataSource also clears the selection and sets the selection to "", but only if the user has already clicked on an item. How can I prevent this?

I have tried assigning DataSource to a new ObservableCollection, though this triggers very strange behaviour: the SelectionChanged event occurs when it shouldn't. After the user clicks on a drop down item, any time the user edits the text, SelectionChanged is triggered though the selection has not changed, resetting the text back to what it was, so the user cannot make any change to the text.

A fix for either of these would be great!


MC Max Clark August 18, 2019 01:47 PM UTC

Hello? Any update on this?

Essentially, I am looking for the correct way to change the values of DataSource in a SfComboBox.


MK Muneesh Kumar G Syncfusion Team August 19, 2019 11:03 AM UTC

Hi Max, 
 
Thanks for your update.  
 
Query 1: Calling .Clear() on the list bounded to DataSource also clears the selection and sets the selection to empty. 
 
We have analyzed your query from our side. When clearing the DataSource, the SelectedItem also get cleared. So that the selected text is getting empty. This is a behavior of SfComboBox. 
 
Query 2: Assigning DataSource to a new ObservableCollection, though this triggers very strange behaviour: the SelectionChanged event occurs when it shouldn't. 
 
We are not clear with your query. Can you please provide your requirement with more detail like image or video representation? Which will be helpful for us to analyze further and provide an appropriate solution.  
  
Thanks,   
Muneesh Kumar G.  
 



MC Max Clark August 19, 2019 03:00 PM UTC

Hi Muneesh,

Thank you for clarifying query 1.

Here is a video of the problem on google drive. I have binded two methods to the combo box in XAML as such:

SelectionChanged="Selected"
ValueChanged="NameSearchAsync"

I put a breakpoint in the Selected method, so we can see when it is called. After clicking on a drop down item, we can see the method is called twice - strange, but no problem for the user. However, if we edit the text after making a selection, the function is called (twice!), as soon as the edit is made, resetting the text back to what was clicked on, making the combobox unusable for the user.

Here is a control video. We can see that the comboBox works as expected. This time, I have commented out the line:

comboBox.DataSource = TrackCollection;

This is the only change I have made, meaning changing the DataSource must cause the problem.

Thanks,
Max


MK Muneesh Kumar G Syncfusion Team August 22, 2019 12:39 PM UTC

Hi Max, 
 
We have analyzed the reported issue “While select the item from suggestion box, SelectionChanged event called twice” from our side. We are unable to reproduce the reported issue in our end. We have prepared the simple sample with given details. Please check with the sample and if the issue mentioned occurs in different scenario. Please modify the sample with the issue reproducing sample which will be helpful for us to analyze further and provide an appropriate solution.  
 
Sample Link: 
 
Thanks, 
Muneesh Kumar G. 
 



MC Max Clark August 24, 2019 03:02 PM UTC

Hi Muneesh,

The root problem doesn't seem to be in the code itself, but perhaps in the setup of SfComboBox.  I have created my own project and changed the code to match the sample you gave me exactly, here.

Despite having identical code, the problem occurs on the project I created and not on the sample you gave me. The SelectionChanged function is not called twice this time, but it still prevents the user from making changes after selecting.

I used Method 1 to install from this page: https://help.syncfusion.com/xamarin/sfcombobox/getting-started.

Thanks,
Max


MK Muneesh Kumar G Syncfusion Team August 26, 2019 12:20 PM UTC

Hi Max,  
   
We regret for your inconvenience,  
 
Still we are not able to replicate the reported problem. So, we have scheduled a web call and posted in the incident. Please follow that for further updates. 
  
Regards, 
Muneesh Kumar G 



SA Safeer Ahmad April 22, 2020 12:36 AM UTC

Hi, I'm facing a similar issue I think. Here is my I'm doing:

In ComboBox_ValueChanged event, I'm calling API to fetch results. This works fine and once I select a value from results, it fires comboBox_SelectionChanging event which then fires ComboBox_ValueChanged again (becuase I selected the value). This goes back to api and fetch results again but doesn't fire the comboBox_SelectionChanging event again (this is right).

How do i get over it? I don't want to keep calling the api after selecting the item.



  private void ComboBox_SelectionChanged(object sender, Syncfusion.XForms.ComboBox.SelectionChangedEventArgs e)
        {
            var value = (e?.Value as Compass.Data.Common.Geolocation)?.DisplayText;
            if (string.IsNullOrEmpty(value)) return;
        }

        private async void ComboBox_ValueChanged(object sender, Syncfusion.XForms.ComboBox.ValueChangedEventArgs e)
        {
            var text = e?.Value;
            if (string.IsNullOrEmpty(text)) return;

            var vm = this.GetViewModel<CriteriaViewModel>();

            vm.Suburb = text;
            if (comboBox.SelectedValue == null &&  !string.IsNullOrWhiteSpace(e.Value) && e.Value.Length > 3)
                await vm.LoadSuburbSelection();
        }

void comboBox_SelectionChanging(System.Object sender, Syncfusion.XForms.ComboBox.SelectionChangingEventArgs e)
        {
           //this fires when i am making my selection and then it refires ComboBox_ValueChanged
        }
 


MS Mugundhan Saravanan Syncfusion Team April 23, 2020 03:57 PM UTC

Hi Saffer,

Thanks for your update.

Query: “ I don't want to keep calling the api after selecting the item.”

In our implementation this is the behavior when the selection has been changed value has updated so value changed event should called. Could you restrict by using bool property in the code behind. We have prepared a simple sample by restrict the value changed while selecting the items. Please check the sample from following

Code:

 
  
private bool IsValuecahnged = true;
private void ComboBox_ValueChanged(object sender, Syncfusion.XForms.ComboBox.ValueChangedEventArgs e)
 
        { 
            if (IsValuecahnged) 
            { 
              // Place your code 
            } 
         else 
            { 
                IsValuecahnged = true; 
            } 
 
        } 
 
        private void ComboBox_SelectionChanged(object sender, Syncfusion.XForms.ComboBox.SelectionChangedEventArgs e) 
        { 
            IsValuecahnged = false; 
       } 


Sample : https://www.syncfusion.com/downloads/support/forum/146682/ze/ComboBoxSample_ValueChange1758425856  


Please let us know if you have any concern.

Regards
Mugundhan S.


SA Safeer Ahmad April 23, 2020 08:09 PM UTC

Thanks, Yes i think this would work. 


SP Sakthivel Palaniyappan Syncfusion Team April 24, 2020 09:17 AM UTC

Hi Safeer,

Thanks for the update.

Please get back us, if you need any further assistance on this.

Regards,
Sakthivel P.
 


Loader.
Live Chat Icon For mobile
Up arrow icon