[CLOSED] ComboBox: Unable to enter a new value that matches to one of existing item IDs

  1. #1

    [CLOSED] ComboBox: Unable to enter a new value that matches to one of existing item IDs

    Hi All,
    I have a combobox with a list of predefined values. Although I need to allow user to enter some new value (have ForceSelection="false" to make it work). Everything is going well, until user tries to enter numbers which equal to IDs of predefined items.
    Please take a look to the example below. Just enter 1 or 2 into the combobox and click somewhere to remove input focus. Text will change to "item 1" or "item 2".
    Looks like combo treats its input text as item ID at some point.

    <%@ Page Language="C#"  %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            var list = new List<object>();
            list.Add(new { ID = 1, Name = "item 1" });
            list.Add(new { ID = 2, Name = "item 2" });
            Store1.DataSource = list;
            Store1.DataBind();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        
        
    <ext:Store ID="Store1" runat="server">
        <Reader>
            <ext:JsonReader IDProperty="ID">
                <Fields>
                    <ext:RecordField Name="ID"/>
                    <ext:RecordField Name="Name"/>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    
    <ext:ComboBox ID="Category" runat="server" AllowBlank="false" 
        TypeAhead="false" Mode="Local" ForceSelection="false" SelectOnFocus="false"
        StoreID="Store1" ValueField="ID" DisplayField="Name" EmptyText="Select a Category">
    </ext:ComboBox>
    
    </body>
    </html>

    Is there any known workaround?
    Thanks
    Last edited by Daniil; Dec 27, 2011 at 2:35 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Yes, ComboBox searches a record on "entered text equals a record's valueField" condition. And I can't see any good way to override it.

    Generally speaking, this is for avoiding ambiguity: the ComboBox getValue method will return "1" for two cases if you'd achieve your requirement:

    1. When a user selects "item 1"
    2. When a user types "1".

    This is a possible ambiguity I'm talking about and the ComboBox's scripts avoid it.

    You could add a new item for a ComboBox using, for example, an additional trigger.
  3. #3
    Thanks,
    That were bad news.
    I came up with ID escaping. Not the best solution, but it works.
  4. #4
    Yes, but you should be sure that a user can't type that escaped ID.

Similar Threads

  1. Replies: 9
    Last Post: Aug 03, 2012, 8:36 AM
  2. [CLOSED] Always selected Item is nothing for combobox as menu item
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 04, 2011, 4:51 PM
  3. Replies: 1
    Last Post: Feb 15, 2011, 12:21 PM
  4. Replies: 6
    Last Post: Jan 12, 2011, 2:37 PM
  5. Ambigous matches
    By DasPhansom in forum Open Discussions
    Replies: 2
    Last Post: Apr 24, 2009, 7:38 PM

Posting Permissions