RadAutoCompletebox - Single Selection

6 posts, 0 answers
  1. Agm
    Agm avatar
    26 posts
    Member since:
    Sep 2012

    Posted 02 Apr 2013 Link to this post

    Hi,
    I am using RadAutocompletebox version 2011 Q3.
    In this i couldnt restrict the user to select single input.
    User should select one input. If he click "X" button,he can select other one in case he want to change the selected one.

    can anyone help me in this?


    Thanking you,


    Regards,
    AGMRAJA.
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 03 Apr 2013 Link to this post

    Hi AGMRAJA,

    Please try using our Selection Mode property that is available after the 2012 Q3 SP1 version of the Telerik controls as explained here.

    Greetings,
    Kate
    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. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marco
    Marco avatar
    5 posts
    Member since:
    Apr 2015

    Posted 01 Apr 2015 in reply to Kate Link to this post

    I'm using TextSettings-SelectionMode="Single" and I am having two problems with that:

    1) selecting an entry whose text is longer than the control width, with either Tab or Enter, produces a line break and makes the control height expand into two lines;

    2) after the first selection it is still possible to enter text in the field, although not autocompleted.
  5. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 06 Apr 2015 Link to this post

    Hello Marco,

    You should simply hook both client-side events in the implementation of the RadAutoComplete as demonstrated below:

      <telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" runat="server" OnClientRequesting="OnClientRequesting" OnClientLoad="OnClientLoad"..... </telerik:RadAutoCompleteBox>
     
    <script type="text/javascript">
                var $ = $telerik.$;
                function OnClientRequesting(sender, args) {
                    if (sender.get_entries().get_count() > 0) {
                        args.set_cancel(true);
                        $(sender._loadingIcon).remove();
                    }
                }
                function OnClientLoad(sender) {
                    $(".racInput").on('keydown', function (e) {
                        if (sender.get_entries().get_count() > 0) {
                            e.stopPropagation();
                            e.preventDefault();
                        }
                    })
                }
            </script>


    Regards,
    Nencho
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  6. Marco
    Marco avatar
    5 posts
    Member since:
    Apr 2015

    Posted 07 Apr 2015 in reply to Nencho Link to this post

    Thank you Nencho, the solution you proposed for the second line expansion of the control worked like a charm.

    As for the second inquiry, I am not sure I understood how exactly I have to use that JavaScript code you posted. Can you please elaborate more on that?

  7. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 09 Apr 2015 Link to this post

    Hello Marco,

    It seems that there has been some issue with this forum post structure. Please refer to my previous post, which contains the reply for your current inquiry. In addition, just to persist the css styling for the single line AutoCompleteBox, I will repost it in this reply :

    <style type="text/css">
           html .RadAutoCompleteBox .racTokenList {
               white-space: nowrap;
           }
           html .RadAutoCompleteBox .racToken,
           html .RadAutoCompleteBox .racInput {
               float: none;
               display: inline-block;
           }
       </style>


    Regards,
    Nencho
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017