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

Can't remove token of an AutoCompleteBox

2 Answers 130 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 01 Jul 2016, 01:21 PM

Hello,

 

I can't remove token from their autocompletebox,when the token is too long (see the picture attached).

 

Here is my code : 

<telerik:RadAutoCompleteBox runat="server" ID="radAutoCompleteBoxSelectionSite" 
                    DropDownAutoWidth="Enabled" Filter="Contains" Visible="True" CausesValidation="False" AutoPostBack="True"
                    Width="100%" EmptyMessage="<%$ Resources:Language, SelectSite%>" InputType="Token"
                    OnEntryAdded="radAutoCompleteBoxSelectionSite_EntryAdded" TextSettings-SelectionMode="Single" OnClientLoad="onLoadAutoComplete" MinimumPrefixLength="0" >
</telerik:RadAutoCompleteBox>

 

And here is my script :

<script type="text/javascript">
            function onLoadAutoComplete(sender, args) {
                window.$telerik.$(sender.get_inputElement()).on('keypress', function (e) {
                    if (sender.get_entries().get_count() > 0) {
                        e.preventDefault();
                    }
                });
            }

</script>

 

I would like to stay in token mode and not in text mode. They still can delete the element with the keyboard but it's not enought clear. Is there any solution ?

Thanks

2 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 06 Jul 2016, 10:32 AM
Hello Paul,

You can use custom css style rules, in order to set a 100% width for the token so it could fit within the RadAutoCompleteBox. Hence, you will be able to show the delete button and achieve the needed behavior.

In the attachment you can find a sample example, on how this could be achieved.

Hope this would help.

Regards,
Nencho
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Paul
Top achievements
Rank 1
answered on 07 Jul 2016, 03:56 PM
Works fine, thanks
Tags
AutoCompleteBox
Asked by
Paul
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Paul
Top achievements
Rank 1
Share this question
or