[OPEN] [#116] Problem to reset a combo

  1. #1

    [OPEN] [#116] Problem to reset a combo

    instead of reset the combo, set the item (Arizona) that has ID = 0.
    I can not change the value to be 0.
    What do you advise me to do to fix this?


    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
      
            this.Store1.DataSource = new object[]
            {
                new object[] { 60, "Alabama", "The Heart of Dixie" },
                new object[] { 1, "Alaska", "The Land of the Midnight Sun" },
                new object[] { 0, "Arizona", "The Grand Canyon State" },
                new object[] { 3, "Arkansas", "The Natural State" }         
            };        
            this.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">
        <title>Basic Hello World Window - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <ext:Button ID="Button1" runat="server" Text="Button #1">
                    <Listeners>
                        <Click Handler="#{FormPanel1}.getForm().reset();" />
                    </Listeners>
                </ext:Button>
            
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="abbr" />
                            <ext:RecordField Name="state" />
                            <ext:RecordField Name="nick" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>            
            </ext:Store> 
             <ext:Store ID="StoreStati" runat="server">
                <Reader>
                     <ext:JsonReader IDProperty="ID">
                        <Fields>
                         <ext:RecordField Name="ID" />  
                         <ext:RecordField Name="Name" />                    
                        </Fields>
                    </ext:JsonReader>
                </Reader>
                <Listeners>
                    <LoadException Handler="Ext.Msg.alert('Employees - Load failed', e.message || response.statusText);" />
                </Listeners>
            </ext:Store>
            <ext:FormPanel
                ID="FormPanel1" 
                runat="server"
                Width="400">
                <Items>            
                 <ext:ComboBox 
                    ID="ComboBox1" 
                    runat="server" 
                    StoreID="Store1" 
                    Editable="false"
                    DisplayField="state"
                    ValueField="abbr"
                    TypeAhead="true" 
                    Mode="Local"
                    ForceSelection="true"
                    EmptyText="Select a state..."
                    Resizable="true"
                    SelectOnFocus="true"
                    />  
                </Items>
           </ext:FormPanel>
      </form>
    </body>
    </html>
    Last edited by Daniil; Jan 04, 2013 at 12:48 PM. Reason: [OPEN] [#116]
  2. #2
    Hi,

    Confirmed. It's a bug in the ComboBox's findRecord method. Thank you for the report.

    The bug happens because condition
    (0 == "")
    is true in JavaScript.

    For now please use either the different from zero 'abbr' or the following fix (see comment in .js).

    Fix
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
    
            this.ComboBox1.GetStore().DataSource = new object[]
            {
                new object[] { 60, "Alabama", "The Heart of Dixie" },
                new object[] { 1, "Alaska", "The Land of the Midnight Sun" },
                new object[] { 0, "Arizona", "The Grand Canyon State" },
                new object[] { 3, "Arkansas", "The Natural State" }        
            };
            this.ComboBox1.GetStore().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">
        <title>Ext.NET Example</title>
        <ext:ResourcePlaceHolder runat="server" />
    
        <script type="text/javascript">
            Ext.form.ComboBox.override({
                findRecord : function(prop, value) {
                    var record;
                    if (this.store.getCount() > 0) {
                        this.store.each(function(r) {
                            if (r.data[prop] === value) { //instead of (r.data[prop] == value)
                                record = r;
                                return false;
                            }
                        });
                    }
                    return record;
                }
            });    
        </script>
    
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:ComboBox 
            ID="ComboBox1" 
            runat="server" 
            DisplayField="state"
            ValueField="abbr">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="abbr" />
                                <ext:RecordField Name="state" />
                                <ext:RecordField Name="nick" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
        </ext:ComboBox>
        <ext:Button runat="server" Text="Reset">
            <Listeners>
                <Click Handler="ComboBox1.reset();" />
            </Listeners>
        </ext:Button>
        </form>
    </body>
    </html>
  3. #3
    Last edited by Daniil; Dec 06, 2010 at 8:03 PM.
  4. #4
    The Sencha ticket is still opened.

    But we decided to fix it on our side. So, it has been fixed in SVN. The fix will appear in the next v1.7 release.

    Created an Issue to monitor Sencha ticket.
    https://github.com/extnet/Ext.NET/issues/116

Similar Threads

  1. Combo Box TEXT Problem
    By EMS in forum 1.x Help
    Replies: 1
    Last Post: Dec 07, 2010, 2:36 PM
  2. Problem with paging in combo box
    By t2kien in forum 1.x Help
    Replies: 0
    Last Post: Nov 10, 2010, 9:34 AM
  3. Replies: 2
    Last Post: Aug 27, 2010, 10:15 AM
  4. Linked Combo Box Problem
    By ary sucaya in forum 1.x Help
    Replies: 0
    Last Post: Jun 04, 2010, 11:40 AM
  5. Combo Box Problem
    By jpmcm88 in forum 1.x Help
    Replies: 2
    Last Post: Jul 15, 2009, 2:59 PM

Tags for this Thread

Posting Permissions