This is a migrated thread and some comments may be shown as answers.

Filter does not work when Clearing the text and selection in Client Side

2 Answers 224 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 28 Apr 2016, 03:29 AM

I am using the RadComboBox with "Contains" filter. The filter does not work properly when clearing the text and selection in the client side script.

C# code:

            _comboBox.Filter = RadComboBoxFilter.Contains;

            if (_comboBox.EnableLoadOnDemand && !AllowCustomText && !_comboBox.CheckBoxes)
            {
                if (String.IsNullOrEmpty(_comboBox.OnClientBlur))
                {
                    _comboBox.OnClientBlur = "function (sender, eventArgs) { var textInTheCombo = sender.get_text(); var item = sender.findItemByText(textInTheCombo); if(!item) { sender.set_text(''); sender.clearSelection(); } }";
                }
            }

Out intent for OnClientBlur is to clear the user input when it losts the focus and there is not a match item. It does clear the text/selection, and show the EmptyMessage, but when it get the focus again, the combobox still show the filtered items which was filtered by the previous input.

 

For example, the combobox has 20 items total. When user inputs a filter and 3 (out of 20) of the items which contains the input characters will show. When user click off the combobox, it clear the text as expected (as none of the items match the input exactly). But when user clicks the combobox again, it still only show the 3 items (instead of the 20 items which is supposed to have as at the moment the text is empty).

Any suggestions to fix the problem I am getting. Thanks a lot.

Regards,

Kevin Hu

2 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 29 Apr 2016, 01:45 AM

I fixed it finally.

at the end of the OnClientBlur event script, I added two lines

_combobox._filterText = "";

and _combobox.requestItems();

0
Dimitar
Telerik team
answered on 29 Apr 2016, 07:16 AM
Hello Kevin,

Thank you for sharing your solution with the community.

Regards,
Dimitar
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
ComboBox
Asked by
Kevin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or