[CLOSED] Combobox Change/Select handler only fires one

  1. #1

    [CLOSED] Combobox Change/Select handler only fires one

    I have a combo box and i need to fire a select or change event when user selects a different item in combobox When I assign a Listner Handler .Listeners(l=>l.Change.Handler = ("SelectItemChange(this);")) it will fire once but nor after that

    SeacrhControl.cshtml
     
    <script>
        function SelectItemChange(combo) {        
            var id = combo.getDisplayValue();          
                alert(id);
            
        }
    </script>
    
    @(Html.X().Panel()
           .AutoDoLayout(true)
           .BodyBorder(0)
           .Border(false)
           .Layout("Table")
           .Items(i => i.Add(
               (Html.X().Button()
                   .Text("Delete")
               )))
           .Items(i => i.Add(
               (Html.X().ComboBox()
                   .Border(false)
                    .Listeners(l=>l.Change.Handler  = ("SelectItemChange(this);"))
                   .Editable(false)
                   .QueryMode(DataLoadMode.Local)
                   .TriggerAction(TriggerAction.All)
                   .SelectOnFocus(true)
                   .EmptyText("Loading.....")
                   .DisplayField("COLUMN_NAME")
                   .ValueField("DATA_TYPE")
                   .PageSize(10)
                   .TypeAhead(true)
                   .Store(
                       (Html.X().Store()
                       .PageSize(10)
                       .AutoLoad(true)
                       .RemotePaging(false)
                       .AutoDataBind(true)
                           .Proxy(
                               (Html.X().AjaxProxy()
                                   .Url(Url.Action("BuildStoreColumnList"))
                               )
                                   .ActionMethods(a => a.Read = HttpMethod.GET)
                                   .Reader(
                                       (Html.X().JsonReader()
                                           .Root("data")
                                       )
                                   ))
                       )
                           .Model(m =>
                                  m.Add((Html.X().Model()
                                            .Fields(f =>
                                                        {
                                                            f.Add((Html.X().ModelField()
                                                                      .Name("COLUMN_NAME")
                                                                      .Type(ModelFieldType.String)
                                                                  ));
                                                            f.Add((Html.X().ModelField()
                                                                      .Name("DATA_TYPE")
                                                                      .Type(ModelFieldType.String)
                                                                  ));
                                                        }
                                            )
                                        )
                                      )
                           )
                           
                   )
                   .Tpl(
                   (Html.X().XTemplate()
                        .Html(@"  <Html>
                            <tpl for=""."">
                                <tpl if=""[xindex] == 1"">
                                    <table class=""cbStates-list"" width=""100%"">
                                        <tr>
                                            <th>COLUMN_NAME</th>
                                            <th>DATA_TYPE</th>
                                        </tr>
                                </tpl>
                                <tr class=""x-boundlist-item"">
                                    <td>{COLUMN_NAME}</td>
                                    <td>{DATA_TYPE}</td>
                                </tr>
                                <tpl if=""[xcount-xindex]==0"">
                                    </table>
                                </tpl>
                            </tpl>
                        </Html>")
                   
                   
                   )
                   )
               )
                 ))
                 .Items(i => i.Add(
                    (Html.X().ComboBox()
                        .Border(false)
                        .Editable(false)
                        .QueryMode(DataLoadMode.Local)
                        .TriggerAction(TriggerAction.All)
                        .SelectOnFocus(true)
                        .EmptyText("Loading.....")
                             .DisplayField("OperatorId")
                             .ValueField("OperatorValue")
                        .PageSize(10)
                        .TypeAhead(true)
                        .Store(
                            (Html.X().Store()
                            .PageSize(10)
                            .AutoLoad(true)
                            .RemotePaging(false)
                            .AutoDataBind(true)
                                .Proxy(
                                    (Html.X().AjaxProxy()
                                             .Url(Url.Action("GetOperators"))
                                    )
                                        .ActionMethods(a => a.Read = HttpMethod.GET)
                                        .Reader(
                                            (Html.X().JsonReader()
                                                .Root("data")
                                            )
                                        ))
                            )
                                .Model(m =>
                                       m.Add((Html.X().Model()
                                                 .Fields(f =>
                                                 {
                                                     f.Add((Html.X().ModelField()
                                                               .Name("OperatorId")
                                                               .Type(ModelFieldType.String)
                                                           ));
                                                     f.Add((Html.X().ModelField()
                                                               .Name("OperatorValue")
                                                               .Type(ModelFieldType.String)
                                                           ));
                                                 }
                                                 )
                                             )
                                           )
                                )
    
                        )
                        .Tpl(
                        (Html.X().XTemplate()
                             .Html(@"  <Html>
                            <tpl for=""."">
                                <tpl if=""[xindex] == 1"">
                                    <table class=""cbStates-list"" width=""100%"">
                                        <tr>
                                            <th>Operator Id</th>
                                            <th>Value</th>
                                        </tr>
                                </tpl>
                                <tr class=""x-boundlist-item"">
                                    <td>{OperatorId}</td>
                                    <td>{OperatorValue}</td>
                                </tr>
                                <tpl if=""[xcount-xindex]==0"">
                                    </table>
                                </tpl>
                            </tpl>
                        </Html>")
    
    
                        )
                        )
                    )
                      ))
           .Items(i => i.Add(
               (Html.X().TextField()
                   .Border(false)
                   .Width(150)
                   // .ID(Guid.NewGuid().ToString())
                   .SelectOnFocus(true)
                   .EmptyText("Loading.....")
               )))
    
    
           )
    Attached Thumbnails Click image for larger version. 

Name:	screenshot_first_time.png 
Views:	126 
Size:	46.7 KB 
ID:	4969   Click image for larger version. 

Name:	screenshot_Second Selection_no_alert.png 
Views:	95 
Size:	13.5 KB 
ID:	4970  
    Last edited by Daniil; Oct 30, 2012 at 3:22 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I think here is a test case below to reproduce your problem.

    So, the problem is the same "values" for the ComboBox's items. Please ensure you bind unique values for the ComboBox's items.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.ComboBox1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "1", "Item 1" },
                    new object[] { "1", "Item 2" },
                    new object[] { "1", "Item 3" }
                };
                store.DataBind();
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:ComboBox 
                ID="ComboBox1" 
                runat="server" 
                DisplayField="text" 
                ValueField="value">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="value" />
                                    <ext:ModelField Name="text" />
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Reader>
                            <ext:ArrayReader />
                        </Reader>
                    </ext:Store>
                </Store>
                <Listeners>
                    <Change Handler="alert('Change');" />
                </Listeners>
            </ext:ComboBox>
        </form>
    </body>
    </html>

Similar Threads

  1. combobox select change to hide some objet
    By snakeeyes in forum 2.x Help
    Replies: 0
    Last Post: Oct 15, 2012, 8:36 AM
  2. [CLOSED] ComboBox fires Select DirectEvent twice
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: May 05, 2011, 9:52 AM
  3. Replies: 1
    Last Post: Dec 21, 2010, 8:49 AM
  4. [CLOSED] [1.0] SelectBox Select event fires twice
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 09, 2009, 2:20 PM
  5. [CLOSED] Select value of combobox on text change of textfield
    By Sharon in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 08, 2009, 7:00 AM

Posting Permissions