AutoCompleteBox with 2 items

6 posts, 0 answers
  1. Ed
    Ed avatar
    33 posts
    Member since:
    Sep 2012

    Posted 11 Dec 2012 Link to this post

    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.
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 13 Dec 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ed
    Ed avatar
    33 posts
    Member since:
    Sep 2012

    Posted 13 Dec 2012 Link to this post

    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
  5. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 19 Dec 2012 Link to this post

    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.
  6. Ed
    Ed avatar
    33 posts
    Member since:
    Sep 2012

    Posted 19 Dec 2012 Link to this post

    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

     

     

     


  7. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 24 Dec 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017