[CLOSED] Combobox Selection doesn't work in SVN#6442

  1. #1

    [CLOSED] Combobox Selection doesn't work in SVN#6442

    Hi,

    There is a problem with selecting item from Combobox dropdown.
    Please use one of the example codes to reproduce the problem:

    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            Store store = this.ComboBox1.GetStore();
            
            store.DataSource = new object[]
            {
                new object[] { ResourceManager.GetIconClassName(Icon.FlagFr), "France"},
                new object[] { ResourceManager.GetIconClassName(Icon.FlagCa), "Canada"},
                new object[] { ResourceManager.GetIconClassName(Icon.FlagDe), "Germany"},
                new object[] { ResourceManager.GetIconClassName(Icon.FlagUs), "United States"},
                new object[] { ResourceManager.GetIconClassName(Icon.FlagIt), "Italy"}
            };
            
            store.DataBind();
    
            this.ResourceManager1.RegisterIcon(Icon.FlagFr);
            this.ResourceManager1.RegisterIcon(Icon.FlagCa);
            this.ResourceManager1.RegisterIcon(Icon.FlagDe);
            this.ResourceManager1.RegisterIcon(Icon.FlagUs);
            this.ResourceManager1.RegisterIcon(Icon.FlagIt);
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>IconCombo - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
        <style>
             .icon-combo-item {
                background-repeat   : no-repeat !important;
                background-position : 3px 50% !important;
                padding-left        : 24px !important;
            }
        </style>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <h1>Render an Icon in ComboBox data items</h1>
    
            <ext:ComboBox 
                ID="ComboBox1" 
                runat="server"
                Width="250"
                Editable="false"
                DisplayField="name"
                ValueField="name"
                QueryMode="Local"
                TriggerAction="All"
                EmptyText="Select a country...">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="iconCls" />
                                    <ext:ModelField Name="name" />
                                </Fields>
                            </ext:Model>
                        </Model>            
                    </ext:Store>
                </Store>
                <ListConfig>
                    <ItemTpl runat="server">
                        <Html>
                            <div class="icon-combo-item {iconCls}">
                                {name}
                            </div>
                        </Html>                    
                    </ItemTpl>
                </ListConfig>
                <Listeners>
                    <Change Handler="if(this.valueModels.length>0) {this.setIconCls(this.valueModels[0].get('iconCls'));}" />
                </Listeners>  
            </ext:ComboBox>    
        </form>
    </body>
    </html>


    Thank you,
    Last edited by fabricio.murta; Jun 30, 2015 at 9:49 PM.
  2. #2
    Hi Matt,

    Thank you for the report!

    This problem has been already fixed in SVN trunk. Here is the updated example. valueCollection should be used instead of valueModels.

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            Store store = this.ComboBox1.GetStore();
    
            store.DataSource = new object[]
            {
                new object[] { ResourceManager.GetIconClassName(Icon.FlagFr), "France"},
                new object[] { ResourceManager.GetIconClassName(Icon.FlagCa), "Canada"},
                new object[] { ResourceManager.GetIconClassName(Icon.FlagDe), "Germany"},
                new object[] { ResourceManager.GetIconClassName(Icon.FlagUs), "United States"},
                new object[] { ResourceManager.GetIconClassName(Icon.FlagIt), "Italy"}
            };
    
            store.DataBind();
    
            this.ResourceManager1.RegisterIcon(Icon.FlagFr);
            this.ResourceManager1.RegisterIcon(Icon.FlagCa);
            this.ResourceManager1.RegisterIcon(Icon.FlagDe);
            this.ResourceManager1.RegisterIcon(Icon.FlagUs);
            this.ResourceManager1.RegisterIcon(Icon.FlagIt);
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>IconCombo - Ext.NET Examples</title>
        
        <style>
            .icon-combo-item {
                background-repeat   : no-repeat !important;
                background-position : 3px 50% !important;
                padding-left        : 24px !important;
            }
        </style>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
            <h1>Render an Icon in ComboBox data items</h1>
    
            <ext:ComboBox
                ID="ComboBox1"
                runat="server"
                Width="250"
                Editable="false"
                DisplayField="name"
                ValueField="name"
                QueryMode="Local"
                TriggerAction="All"
                EmptyText="Select a country...">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="iconCls" />
                                    <ext:ModelField Name="name" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ListConfig>
                    <ItemTpl runat="server">
                        <Html>
                            <div class="icon-combo-item {iconCls}">
                                {name}
                            </div>
                        </Html>
                    </ItemTpl>
                </ListConfig>
                <Listeners>
                    <Change Handler="if(this.valueCollection.getCount() > 0) {this.setIconCls(this.valueCollection.getAt(0).get('iconCls'));}" />
                </Listeners>
            </ext:ComboBox>
        </form>
    </body>
    </html>
  3. #3

    Another changes...

    Thank you Daniil,

    I just went through my code where I was extending the comobox a bit and noticed that record.raw was removed and record.data must be used.


    beforeselect: function (selectionModel, record) {
    
     //  record.raw was removed
     //  record.data must be used
    
    }
    That was nature of my problem in this case. Please close the thread.

    Best Regards,

Similar Threads

  1. Combobox Select OnEvent doesn't work
    By neosaint in forum 2.x Help
    Replies: 2
    Last Post: Jun 09, 2014, 1:22 PM
  2. Replies: 5
    Last Post: Jul 12, 2013, 3:29 PM
  3. [CLOSED] Combobox.SelectedItem.Index doesn't work everytime
    By profitsistemas in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Feb 04, 2013, 4:11 AM
  4. Replies: 1
    Last Post: Aug 24, 2012, 8:55 PM
  5. [CLOSED] Doesn't work ToolTips for ComboBox Items
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 15, 2011, 3:30 PM

Tags for this Thread

Posting Permissions