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

Auto Complete Minimum number of characters for web service call

1 Answer 176 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 20 Mar 2009, 06:12 PM
I have a combobox as displayed below, and I was wondering if there is a setting to control the minimum number of characters to display before
the service gets called. In other words, I would like to call the service only after the user typed in 3 or more characters.
Also, when the control initially loads, there are no rows, as soon as I start typing, a blank drop down appears. Is there a way to
supress the display the dropdown if there are no rows?

                                                
<script type="text/javascript">  
                                                    function OnClientItemsRequesting(sender, eventArgs) {  
                                                        var context = eventArgs.get_context();  
                                                        context["prefixText"] = eventArgs.get_text();  
                                                    }  
                                                </script> 
                                                <telerik:RadComboBox ID="rcCompany" runat="server" 
                                                    AllowCustomText="true" 
                                                    DataTextField="Name" 
                                                    DataValueField="CompanyId" 
                                                    Height="200px" 
                                                    Width="400px" 
                                                    DropDownWidth="400px" 
                                                    MarkFirstMatch="true"                                                          
                                                    Text='<%# Bind("CompanyName") %>' 
                                                    EnableLoadOnDemand="true" 
                                                    ShowMoreResultsBox="true" 
                                                    EnableVirtualScrolling="true" 
                                                    OnClientItemsRequesting="OnClientItemsRequesting">  
                                                    <WebServiceSettings Method="GetCompletionList" 
                                                        Path="AutoCompleteCompany.asmx" /> 
                                                </telerik:RadComboBox> 
 

1 Answer, 1 is accepted

Sort by
0
Jim
Top achievements
Rank 1
answered on 20 Mar 2009, 06:23 PM
function OnClientItemsRequesting(sender, eventArgs)    
       {    
           var textvalue = sender._inputDomElement.value;    
              
           if (textvalue.length < 3)    
           {    
                eventArgs.set_cancel(true);    
           }    
       }    
 
OK, here is the answer to my own question.
Tags
ComboBox
Asked by
Jim
Top achievements
Rank 1
Answers by
Jim
Top achievements
Rank 1
Share this question
or