Can't remove token of an AutoCompleteBox

3 posts, 0 answers
  1. Paul
    Paul avatar
    3 posts
    Member since:
    Mar 2015

    Posted 01 Jul Link to this post

    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. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 06 Jul Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Paul
    Paul avatar
    3 posts
    Member since:
    Mar 2015

    Posted 07 Jul in reply to Nencho Link to this post

    Works fine, thanks
Back to Top