Filtering in a combobox and populating another cb based on selection

(1) I am trying to setup filtering on my combobox but not having much luck. With the IsEditable=true set, the combobox accepts values not on the list, it doesn't look like the 'not Found' works either. 
My combobox simply displays all Countries from asp.net core CultureInfo.GetCultures(CultureTypes.SpecificCultures)
<border:SfBorder
    Padding="6,0,0,0"
    BorderColor="{Binding Source={x:Reference CountryPicker}, Path=IsFocused, Converter={StaticResource ColorConverter}, ConverterParameter=3}"
    Style="{StaticResource FormBorderStyle}">
                        <comboBox:SfComboBox
        x:Name="CountryPicker"
        AllowFiltering="True"
        DataSource="{Binding Countries}"
        DisplayMemberPath="Value"
        IsEditableMode="True"
        NoResultsFoundText="Country not found"
        Style="{StaticResource ComboBoxStyle}"
        Watermark="Country">
                            <comboBox:SfComboBox.DropDownButtonSettings>
                                <comboBox:DropDownButtonSettings>
                                    <comboBox:DropDownButtonSettings.View>
                                        <Label
                        Margin="0"
                        FontFamily="{StaticResource FontIcons}"
                        FontSize="15"
                        HorizontalTextAlignment="Center"
                        Text="{StaticResource DropDown}"
                        TextColor="{DynamicResource Gray-600}"
                        VerticalTextAlignment="Center" />
                                    </comboBox:DropDownButtonSettings.View>
                                </comboBox:DropDownButtonSettings>
                            </comboBox:SfComboBox.DropDownButtonSettings>
                        </comboBox:SfComboBox>
                    </border:SfBorder>

(2) I am also trying to figure out how I can connect the countries box to populate a States combobox if 'United States' is selected as the country, and if not make it not show any state and become a textbox.

Would y'all have an example for these cases?


1 Reply

SP Sakthivel Palaniyappan Syncfusion Team February 28, 2020 11:31 AM UTC

Hi Reza,

Greetings from Syncfusion.

Query 1 : I am trying to setup filtering on my combobox but not having much luck. With the IsEditable=true set, the combobox accepts values not on the list, it doesn't look like the 'not Found' works either.

We have validated  your query and we would like to know that the default IsEditable behavior of SfComboBox accepts all the characters entered, and also when the text entered, the text is not in the list then the NoResultFoundText is shown in the list of suggestions, not in the field of ComboBox.

Query 2 : I am also trying to figure out how I can connect the countries box to populate a States combobox if 'United States' is selected as the country, and if not make it not show any state and become a textbox.

We have achieved your requirement of “Populating ComboBox based on other ComboBox” by using the SelectionChanged event as like below code snippet

XAML:
 
<border:SfBorder 
    Padding="6,0,0,0" 
    BorderColor="Green"> 
        <comboBox:SfComboBox x:Name="CountryBox" 
        AllowFiltering="False" 
        DataSource="{Binding Countries}" 
        DisplayMemberPath="Country" 
        IsEditableMode="True" FocusChanged="CountryPicker_FocusChanged" 
        SelectionChanged="CountryPicker_SelectionChanged" 
        NoResultsFoundText="Country not found" 
        Watermark="Country"> 
 
        </comboBox:SfComboBox> 
    </border:SfBorder> 
 
        <border:SfBorder BorderColor="Red"> 
            <comboBox:SfComboBox x:Name="stateBox" Watermark="State"/></border:SfBorder> 
 

C#:


 
  private void CountryPicker_SelectionChanged(object sender, Syncfusion.XForms.ComboBox.SelectionChangedEventArgs e) 
        { 
            stateBox.DataSource = (e.Value as State).States; 
            stateBox.SelectedItem = null; 
            stateBox.SelectedIndex = 0; 
        } 

We have created sample based on your requirement, please find the sample from below.

Sample link :
https://www.syncfusion.com/downloads/support/directtrac/general/ze/AutoCompleteSample570239778.zip

Please let us know if you have any other queries.

Regards,
Sakthivel P.


Loader.
Up arrow icon