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
9 Answers, 1 is accepted
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.

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));
}
}
.
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.

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"
/>
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.

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
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

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
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