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

How to prevent clear text when AlllowCustomEntry is set to False?

9 Answers 62 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Yan Moura asked on 18 Jan 2021, 06:45 PM

I realized that if the "AllowCustomEntry" property is set to FALSE whenever I strike enter, space or even click mouse the contents of the text field will be cleared. How can I prevent it?

Thanks!

9 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 21 Jan 2021, 03:01 PM

HI Yan,

I tested the AutoCompleteBox with AllowCustomEntry set to False, but its content is not cleared at my end after I press Enter (or click into the control). Can you, please provide some more details on the exact scenario leading to the problem?

  • Can you verify that there are not any JavaScript errors thrown on the page?
  • Can you ensure that the control is used in AutoID mode and the static client IDs are not supported? (make sure to remove)

If none of the above is the case, please, send me a small page where I can reproduce the problem and examine the exact setup leading to it.

Regards,
Vessy
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 21 Jan 2021, 03:13 PM
Hi Vessi, it will clear when you type something that does not have a match in the dropdown.
0
Vessy
Telerik team
answered on 22 Jan 2021, 05:39 PM

Hi Yan,

I tested the control with not matching words, but it is not being cleared after pressing enter. You can see a video from my test here:

http://somup.com/crV3bzoxm0

        <telerik:RadAutoCompleteBox RenderMode="Lightweight" runat="server" ID="RadAutoCompleteBox1"
            EmptyMessage="Please type here" AllowCustomEntry="false"
            DataSourceID="SqlDataSource1" DataTextField="FirstName"
            InputType="Text" Width="350" DropDownWidth="150px">
        </telerik:RadAutoCompleteBox>

        <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT [FirstName], [LastName], [EmployeeID] FROM [Employees]"></asp:SqlDataSource>
        <script>
Below you can see the setup I am using for my test:

 

Regards,
Vessy
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 22 Jan 2021, 07:21 PM

You can see it happening here.

This is my RadAutoCompleteBox setup:

<telerik:RadAutoCompleteBox RenderMode="Lightweight" runat="server" ID="RadAutoCompleteBox1" ClientID="RadAutoCompleteBox1"
            autopostback="true"
            DataSourceID="SqlDataSource1" DataTextField="xxxxx" DataValueField="yyyyy" InputType="Token" Width="100%" Visible="true"
            AllowCustomEntry = "false"
            DropDownWidth="300px"
            >
        </telerik:RadAutoCompleteBox>

 

0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 22 Jan 2021, 07:23 PM
Try to type in something like lorem. you will see that the dropdown will not show up (in fact it will show up with some contents while you are typing but at the end it won't because there is not the word "lorem" in our list). Then click anywhere outside the text field. You will see that the word lorem will be cleared.
0
Vessy
Telerik team
answered on 27 Jan 2021, 10:54 AM

Hi Yan,

The behavior faced in the linked URl is expected due to the enabled AutoPostBack and the disabled custom text of the control. When a custom text is entered in the controls it does not selects an item from the list, but rather creates a new on with the entered text. If the AllowCustomEntry property is disabled, the control does not create such an item, thus there is no any selected item when the control is blurred (and respectively, a Postback is triggered) leading to the cleared input.

Setting the AutoCompleteBox's AllowCustomEntry="true" and/or AutoPostback="False" is the way to keep the inserted non-matching words:

        <telerik:RadAutoCompleteBox RenderMode="Lightweight" ID="RadAutoCompleteBox1" runat="server" InputType="Text" AllowCustomEntry="true" Font-Size="Small" >
         ...
         </telerik:RadAutoCompleteBox>

Regards,
Vessy
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 27 Jan 2021, 07:39 PM
I see, well in this scenario setting AllowCustomEntry to true is not an option due to the way as we want the tool working. I understand that in this case it's a non "workaroundable" limitation of the control. I appreciate you take your time to clarify this.
0
Vessy
Telerik team
answered on 28 Jan 2021, 07:02 AM

Hi,

You are welcome, Yan! I just have to clarify that this is not a limitation of the control, but is its designed behavior when the AllowCustomEntry is disabled and a Postback is performed. There are two possible workarounds:

  • enable the AllowCustomEntry option
  • disable the AutoPostback of the control

Regards,
Vessy
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 29 Jan 2021, 08:46 PM
Thank you!
Tags
AutoCompleteBox
Asked by
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Answers by
Vessy
Telerik team
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Share this question
or