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

RadAutoCompletebox - Single Selection

5 Answers 543 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Agm
Top achievements
Rank 1
Agm asked on 02 Apr 2013, 07:18 PM
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.

5 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 03 Apr 2013, 08:08 AM
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.
0
Marco
Top achievements
Rank 1
answered on 01 Apr 2015, 09:01 AM
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.
0
Nencho
Telerik team
answered on 06 Apr 2015, 07:16 AM
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.

 
0
Marco
Top achievements
Rank 1
answered on 07 Apr 2015, 02:46 PM

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?

0
Nencho
Telerik team
answered on 09 Apr 2015, 12:51 PM
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.

 
Tags
AutoCompleteBox
Asked by
Agm
Top achievements
Rank 1
Answers by
Kate
Telerik team
Marco
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or