EnableLoadOnDemand

4 posts, 0 answers
  1. Kaushal
    Kaushal avatar
    8 posts
    Member since:
    Mar 2012

    Posted 17 May 2012 Link to this post

    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.
  2. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 21 May 2012 Link to this post

    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.
  3. Ceki Granti
    Ceki Granti avatar
    27 posts
    Member since:
    Aug 2006

    Posted 01 Jun 2012 Link to this post

    Dear Ivana,

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

    Thanks,
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 01 Jun 2012 Link to this post

    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.
Back to Top