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

AutoCompleteBox with 2 items

5 Answers 42 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 11 Dec 2012, 01:52 PM
I have found that, when you have only 2 items in the returned list, it will always select the second item. This happens both in text and token modes.

5 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 13 Dec 2012, 03:55 PM
Hi Ed,

I tried to reproduce the issue with this online demo - but without success.
Please take a look at this online demo - maybe I miss something?

Regards,
Kalina
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
Ed
Top achievements
Rank 1
answered on 13 Dec 2012, 06:15 PM
That demo is a video, which does not allow me to see the code. I can't verify that my code is correct.

This is my definition of the control:

 

<telerik:RadAutoCompleteBox ID="StreetAutoCompleteBox" runat="server" DataSourceID="StreetDataSource"
                        DataTextField="Street" DataValueField="Street" Width="30em" Filter="StartsWith"
                        OnClientRequesting="AutoCompleteBox_Requesting" InputType="Text">
                    </telerik:RadAutoCompleteBox>

And the javascript function is:

 

 

 

function AutoCompleteBox_Requesting(sender, args)
{
    if (sender.get_text().length < 3)
    {
        args.set_cancel(true);
    }
}
The Data Source is defined as:
<asp:LinqDataSource ID="StreetDataSource" runat="server" ContextTypeName="EnterpriseWeb.DataContracts.Device.DeviceDataContext"
    EntityTypeName="" OrderBy="Street" TableName="InstallationStreetRows" Where="InstallationId == @InstallationId"
    OnSelecting="StreetDataSource_Selecting">
    <WhereParameters>
        <asp:Parameter Name="InstallationId" Type="Int16" />
    </WhereParameters>
</asp:LinqDataSource>
Whenver there are only 2 items returned by the data source, no matter where I click to select one, I always get the second one.

OS: Windows 7 x64
Telerik: Q3 2012
0
Kalina
Telerik team
answered on 19 Dec 2012, 11:55 AM
Hi Ed,

Indeed, I have recorded a video that represents the test that I have made with this online demo.
I am afraid that the code provided here is not sufficient for us to reproduce the issue - simply we do not have the datasouce that you use on our side.
That is why I created a sample using the Northwind database and tested the control behaviour again. However I was not able to reproduce the issue.

I am suggesting you to perform a test with my sample.
Please download the page and database attached here, run the sample and type "con" in the control input - two categories will be displayed in the dropdown (Condiments and Confections).
Please test if you can select the first or second category and let me know the result.

All the best,
Kalina
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
Ed
Top achievements
Rank 1
answered on 19 Dec 2012, 04:11 PM

This does work.

 

Chalk this up to programmer head space

I did, however, find another issue. In the function, AutoCompleteBox_Requesting, sender.get_text().length > 3 returns the length of all of the text in the control. This means that the test for at least 3 characters before opening the drop down will fail if there is at least one entry already present. The code should be: sender.get_inputElement().value.length < 3

 

 

 


0
Kalina
Telerik team
answered on 24 Dec 2012, 09:54 AM
Hello Ed,

I am glad that you managed to find a solution for the issue and thank you for posting if here.

Kind regards,
Kalina
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.
Tags
AutoCompleteBox
Asked by
Ed
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Ed
Top achievements
Rank 1
Share this question
or