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

EnableLoadOnDemand

3 Answers 209 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kaushal
Top achievements
Rank 1
Kaushal asked on 17 May 2012, 03:57 PM
Hi,
I have a radcombobox where I have EnableLoadonDemand is True. When I type "America" in the dropdownlist, it searches first for all "A" then "AM" then "AME" and so on. For my project, getting data takes a while so each search makes dropdownlist slower. What I would like to do is after user type a letter or word, I want to wait for a second then go for search. so instead of making multiple trips to sever, it will make only 1 trip. Ofcourse, User will wiat for a second but that's better than multiple roundtrip to server.

Hope this makes sense.

Thanks in advance for youe help.

3 Answers, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 21 May 2012, 01:41 PM
Hello Kaushal,

You could define a restriction for the length of the text typed when demand for new items from the server occurs.
To achieve the aforementioned you need to subscribe to the OnItemsRequesting client event and add the following code in it:
function OnClientItemsRequesting(sender, eventArgs) {
    if (eventArgs.get_text().length < 5)
        eventArgs.set_cancel(true)
    else
        eventArgs.set_cancel(false);
}
This will cancel the demand for items if the length of the typed text is smaller than 5 letters.

I hope this will help.

All the best,
Ivana
the Telerik team
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 their blog feed now.
0
Ceki Granti
Top achievements
Rank 1
answered on 01 Jun 2012, 05:44 AM
Dear Ivana,

Can you also help on how to open suggestionlistbox after typing 5th letter, instead of opening immediately?

Thanks,
0
Princy
Top achievements
Rank 2
answered on 01 Jun 2012, 08:51 AM
Hi,

Try the following code snippet to open DropDown only after typing the 5th character.

JS:
<script type="text/javascript">
    var i = 0;
    function OnClientItemsRequesting(sender, args)
       {
          if (args.get_text().length < 5)
             args.set_cancel(true)
          else
           {
             i = 1;
             args.set_cancel(false);
           }
       }
    function OnClientDropDownOpening(sender, args)
       {
          if (i != 1)
             args.set_cancel(true);
       }
</script>

Hope this helps.

Regards,
Princy.
Tags
ComboBox
Asked by
Kaushal
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Ceki Granti
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or