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

Auto Complete combo box Prefix length

7 Answers 192 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Anand
Top achievements
Rank 1
Anand asked on 18 Apr 2008, 07:06 AM
Hi,

Is it possible to set minimum prefix length for Auto complete combo

like When i enters "an" then only it should show the list of name start with "an"

and not on just click

Thanks
Anand

7 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 18 Apr 2008, 03:25 PM
Hi Anand,

Please have a look at our online example -http://www.telerik.com/demos/aspnet/prometheus/ComboBox/Examples/Functionality/AutoCompleteClientSide/DefaultCS.aspx

It illustrates how the MarkFisrMatch property of RadComboBox works.

If you set the MarkFisrMatch property of RadComboBox to true the item starting with "an" will be highlighted.

Hope this helps.

Sincerely,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Paul Hopper
Top achievements
Rank 1
answered on 18 Apr 2008, 06:16 PM
I believe I am looking for the same thing as Anand, which is not the same as the MarkFirstMatch property.

In my case, I am trying to use a webservice to return items for the combo box, but I want the user to have to type in at least two characters before the webservice is called.  (Otherwise, the webservice would return a lot of items!)

I've tried to do this using the OnClientItemsRequesting property and cancelling it (return false) if the context filter's length is less than 2, but this does not work and I can't find examples of this behavior anywhere.  Is this possible?  If not, please log it as a feature request.
0
Anand
Top achievements
Rank 1
answered on 21 Apr 2008, 06:24 AM
Hi Thanks for reply,

I also want the same behavious as said by paul,

i dint want to show all items on first ,I want that the item list only display when i enter two charecters

pls suggest any solution

thanks
0
Rosi
Telerik team
answered on 21 Apr 2008, 07:52 AM
Hi all,

This could be easily achieved by using the following approach:

1.Hook on OnClientItemsRequesting event of RadComboBox.
2.Use the following code in its event handler:

function OnClientItemsRequesting(sender,args)  
{  
   var text = args.get_text();  
   if( text.length < 2)  
  {  
       args.set_cancel(true);  
  }  
 
 

This will cancel the request if the length of the entered text is less than 2 symbols

Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Anand
Top achievements
Rank 1
answered on 22 Apr 2008, 12:39 PM
Hi Rosi ,

Thanks for ur help,
i was unable to find the function  args.set_cancel(true);  
can you provide the working example of the same.

Thanks
Anand
0
Nikolay
Telerik team
answered on 22 Apr 2008, 01:54 PM
Hi Anand,

The set_cancel method can be accessed using the event arguments. In the example below the event arguments passed to the event handler are contained within the args object.

I attached a small and running example to this thread. Please download the files and give them a go.

If you remove the OnClientItemsRequesting event handler, the items will be added as expected.

I hope this will get you started.

Sincerely yours,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jim
Top achievements
Rank 1
answered on 20 Mar 2009, 06:25 PM
    <script type="text/javascript">  
        function OnClientItemsRequesting(sender, eventArgs) {  
            var context = eventArgs.get_context();  
            context["prefixText"] = eventArgs.get_text();  
              
            //Don't send the request until the user types in 4 or more characters  
            if (eventArgs.get_text().length <= 3) {  
                eventArgs.set_cancel(true);   
            }  
        }  
    </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> 
 
Tags
ComboBox
Asked by
Anand
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Paul Hopper
Top achievements
Rank 1
Anand
Top achievements
Rank 1
Nikolay
Telerik team
Jim
Top achievements
Rank 1
Share this question
or