Losing focus clears Text when IsFilteringEnabled="True"

10 posts, 1 answers
  1. Peter
    Peter avatar
    5 posts
    Member since:
    Jun 2014

    Posted 24 Feb 2015 Link to this post

    Hello,

    I want to use the Combobox with IsFilteringEnabled="True" to allow users to select items from a combobox.
    However users should also be able to enter new things, that are not (yet) available in the list. Kind of like a recently used list.

    When I enable filtering the combobox always clears itself when the focus is lost, thus my users can never enter anything new.
    Is there a way to turn this off?
    Or is there any other way I can do this?

    Thanks!

    Regards,
    Peter
  2. Nasko
    Admin
    Nasko avatar
    726 posts

    Posted 26 Feb 2015 Link to this post

    Hi Peter,

    By design when you type a text in an editable RadComboBox and no item matches this text as soon as the control loses focus it is set to null - that behavior is observed when IsFilteringEnabled is set either to True or False.  Could you please provide us some more detailed information about your scenario and the desired functionality -  thus, we could be able to provide you with a prompt approach how to achieve it? 

    We're looking forward to hearing from you.

    Regards,
    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Peter
    Peter avatar
    5 posts
    Member since:
    Jun 2014

    Posted 26 Feb 2015 in reply to Nasko Link to this post

    Hi Nasko,

    I know that the RadComboBox does this by design. Thats is why I'm asking how to achieve this.

    So here is what I'm trying to do:

    I want to be able to give the user a list of his recent queries, think database queries, and the combobox should allow to search in these recent queries, that is the reason for IsFilteringEnabled set to True.

    But the user has to be able to enter new queries that do not yet exist in the recent queries.
    And that is not possible when IsFilteringEnabled set to True because it clears the text when the focus is lost and the entered text is not in the recent queries list.

    I can't attach a project here so here is some snippets of code.

    The Xaml looks like this:
    <StackPanel>
            <telerik:RadComboBox Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         ItemsSource="{Binding RecentQueries}"
                         IsEditable="True"
                         IsFilteringEnabled="True"
                         TextSearchMode="Contains"
                         OpenDropDownOnFocus="True"/>
             
            <Button Click="ExecuteQuery">
                Execute Query
            </Button>
        </StackPanel>

    And the code-behind
    public partial class MainWindow : Window, INotifyPropertyChanged
        {
            private string _queryText;
            private readonly ObservableCollection<string> _recentQueries = new ObservableCollection<string>(new []
            {
                "Some old query",
                "Some older query",
                "Some very old query",
            });
     
            public MainWindow()
            {
                InitializeComponent();
     
                DataContext = this;
            }
     
            public string QueryText
            {
                get { return _queryText; }
                set
                {
                    if(_queryText == value)
                        return;
                    _queryText = value;
     
                    OnPropertyChanged();
                }
            }
     
            public ObservableCollection<string> RecentQueries
            {
                get { return _recentQueries; }
            }
     
            private void ExecuteQuery(object sender, RoutedEventArgs e)
            {
                if(String.IsNullOrEmpty(QueryText))
                    return;
     
                //Execute the query here.
     
                //Add the query to the recentqueries list to make it available in the future
                if (!RecentQueries.Contains(QueryText))
                {
                    RecentQueries.Insert(0, QueryText);
                }
                else
                {
                    RecentQueries.Move(RecentQueries.IndexOf(QueryText), 0);
                }
            }
     
            public event PropertyChangedEventHandler PropertyChanged;
     
            [NotifyPropertyChangedInvocator]
            protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
            {
                var handler = PropertyChanged;
                if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }


    .
























  4. Answer
    Nasko
    Admin
    Nasko avatar
    726 posts

    Posted 26 Feb 2015 Link to this post

    Hello Peter,

    One possible approach that we could suggest you in order to achieve the desired functionality is to preserve the Text into a temporary variable and to handle the LostFocus event of RadComboBox. So, when the control loses its focus the event will fire and you could add the preserved variable into he collection of items. Please, check the attached sample project that demonstrates the described above approach.

    Hopes this helps.

    Regards,
    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Peter
    Peter avatar
    5 posts
    Member since:
    Jun 2014

    Posted 27 Feb 2015 Link to this post

    I did not notice that the Text property was being set to null.


    I was able to solve my problem by disallowing setting of null to my QueryText property.

    public string QueryText
    {
        get { return _queryText; }
        set
        {
            if(_queryText == value || value == null)
                return;
            _queryText = value;
     
            OnPropertyChanged();
        }
    }

    Additionally I also had to set CanAutocompleteSelectItems to False to avoid the Combobox automatically selectiong the item that was matching best to the QueryText.

    The xaml looks like this:
    <telerik:RadComboBox x:Name="RadComboBox" Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         ItemsSource="{Binding RecentQueries}"
                         IsEditable="True"
                         IsFilteringEnabled="True"
                         TextSearchMode="Contains"
                         CanAutocompleteSelectItems="False"
                         OpenDropDownOnFocus="True"/>
  6. Nasko
    Admin
    Nasko avatar
    726 posts

    Posted 27 Feb 2015 Link to this post

    Hello Peter,

    We are glad that you've managed to achieve the desired. Please do not hesitate to contact us if you have any additional questions or concerns.

    Regards,
    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Naresh
    Naresh avatar
    2 posts
    Member since:
    Sep 2018

    Posted 06 Sep 2018 in reply to Nasko Link to this post

    Radcombobox clears the text when loaded for the searched filter.

    I have entered a text to filter the combo box items, once got filtered the filtered text is cleared.

    Also in the first search lets say we select an item(Item1) and for the second search too we selected another item(Item2).

    After second search, the first selected item(Item1) gets cleared.

    Please help me on this

  8. Stefan
    Admin
    Stefan avatar
    1073 posts

    Posted 11 Sep 2018 Link to this post

    Hi Naresh,

    In order to enable selection of multiple items, you can set the AllowMultipleSelection property of the control to true. More information can be found in the Multiple Selection help article. As to the filtering text being cleared, can you please elaborate on how exactly is this behavior reproduced?

    Regards,
    Stefan
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  9. Naresh
    Naresh avatar
    2 posts
    Member since:
    Sep 2018

    Posted 11 Sep 2018 in reply to Stefan Link to this post

    Hi Stefan,

    Thanks for your reply.
    we are facing many issues while using Telerik Multi Select drop down.
    I request you to please help on each and every issue explained below in detail.

    Our scenario is loading multiple values(20k) into multi select drop down.
    Below are the issue we are facing in this action:

    Issue #1.
    Load times is approximately 45sec to bind the control, but after binding and while expanding the item list(by clicking on arrow) took 2mins to expand.
    We have tried partial loading by keeping ItemsPerRequest as 500.
    Is there any other way to reduce the delay by loading the entire 20k items?

    Issue2#:  
    During search, when we type a letter, it goes off in seconds.
    For example, lets say we entered 's' to filter the results, but the entered letter(s) gets clear without filtering the results.

    Issue3#:
    In search box the selected items remains same even we clear the selection.
    For example, When Item#’s are selected and clicked on the cancel button(x), the item#’s selected are removed in the textbox whereas those are still selected 
    in the list displayed(have to manually de-select those)

    Thanks in advance

  10. Stefan
    Admin
    Stefan avatar
    1073 posts

    Posted 13 Sep 2018 Link to this post

    Hi Naresh,

    I will try to address your questions in the same order.

    1. RadComboBox can be configured to support UI Virtualization. The downside of this is that filtering is not supported when the control is virtualized. Please, take a look at the RadComboBox Virtualization topic for more information.

    2 & 3. I cannot reproduce both of the reported issues. Attached to my reply you can find a sample application which I used for testing. It is the SelectedItems Binding SDK Example. Can you please check it out? Am I missing something?

    Regards,
    Stefan
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top