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

OnClientItemsRequesting event for RadDropDownTree

1 Answer 83 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Tauqir
Top achievements
Rank 1
Tauqir asked on 05 Dec 2013, 11:35 AM
I am using the MinFilterLength property for filtering items in the RadDropDownTree. Assume the MinFilterLength property is set to 3.
If I now enter 3 characters, the results are filtered correctly. However, if I delete a character, the results are not reset.
How can I achieve this?
I searched online, and found a possible solution here: http://www.telerik.com/community/forums/aspnet-ajax/combobox/hide-disable-the-loading-text-on-itemsrequested.aspx.
However, RadDropDownTree does not have a OnClientItemsRequesting event. Which event can I use to achieve the same behavior?
Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Boyan Dimitrov
Telerik team
answered on 10 Dec 2013, 11:01 AM
Hello,

Your observations are absolutely correct and we will include a fix for this issue in our upcoming service pack release.  In the meantime you can use this workaround
//markup code
<telerik:RadDropDownTree ID="RadDropDownTree1" runat="server" DefaultMessage="Select location" Skin="Default"
       EnableFiltering="true" FilterSettings-Highlight="Matches" FilterSettings-MinFilterLength="3">
   </telerik:RadDropDownTree>
//JavaScript
<script type="text/javascript">
 
           var isBackspacePressed = false;
 
           function pageLoad() {
 
               $find("RadDropDownTree1")._manager._shouldFilter = function (text) {
 
                   var shouldFilter = ((text.length >= this._minFilterLength || (text == "" && this._minFilterLength == 1)) || isBackspacePressed);
 
                   isBackspacePressed = false;
 
                   return shouldFilter;
 
               }
 
               $find("RadDropDownTree1")._manager._onFilterKeyUp = function (e) {
                   //debugger
 
                   var text = e.target.value,
                       key = Sys.UI.Key,
                       keyCode = e.keyCode || e.which;
 
 
 
                   if (keyCode == key.backspace) {
                       isBackspacePressed = true;
                   }
                   else {
                       isBackspacePressed = false;
                   }
 
                   switch (keyCode) {
                       case 16: // shift
                       case 17: // ctrl
                       case 18: // alt
                       case key.home:
                       case key.end:
                       case key.enter:
                       case key.tab:
                           e.stopPropagation();
                           e.preventDefault();
                           break;
                       case key.left:
                       case key.right:
                       case key.up:
                           break;
                       case key.down:
                           this._focusNextElement(e);
                           break;
                       case key.pageUp:
                       case key.pageDown:
                           break;
                       case key.esc:
                           break;
                       default:
                           this._handleFiltering(text);
                           break;
                   }
               }
           }
           
       </script>



Regards,
Boyan Dimitrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
DropDownTree
Asked by
Tauqir
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or