Combobox - Change of behavior

  1. #1

    Combobox - Change of behavior

    Hi,

    Am attempting to upgrade our project to 2.0 RC2. When calling SetValue on a combobox (linked to a store) from codebehind we are getting a change in behaviour from 1.x.

    The old behaviour was that the record in the store was selected and the displayfield was shown. The new behaviour is that the value set in SetValue function is being shown.

    Can you tell me is this by design and if so how do I replicate the old behaviour. Code below for testing
    thanks
    Dermot

    <%@ Page Language="C#" AutoEventWireup="true" %>
    
    
    <!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 runat="server">
        <title></title>
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                storeCbb.DataSource = new object[]
                {
                    new object[] { 0, "John" },
                    new object[] { 1, "Dermot" }
                };
                storeCbb.DataBind();
            }
    
    
            protected void btTest_Click(object sender, DirectEventArgs e)
            {
                cbb.SetValue("0");
            }
    
    
            protected void btTest2_Click(object sender, DirectEventArgs e)
            {
                cbb.SetValue("1");
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
    
    
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
    
            <ext:Button runat="server" ID="btnTest" Text="SetValue 0">
                <DirectEvents><Click OnEvent="btTest_Click"></Click></DirectEvents>
            </ext:Button>
    
    
            <ext:Button runat="server" ID="Button1" Text="SetValue 1">
                <DirectEvents><Click OnEvent="btTest2_Click"></Click></DirectEvents>
            </ext:Button>
    
    
            <ext:ComboBox ID="cbb" runat="server" Editable="false" FieldLabel="Name" AnchorHorizontal="100%" DisplayField="Name" ValueField="Id">
                <Store>
                    <ext:Store ID="storeCbb" runat="server">
                        <Model>
                            <ext:Model ID="Model1" runat="server">
                                <Fields>
                                    <ext:ModelField Name="Id" Type="Int" />
                                    <ext:ModelField Name="Name" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
            </ext:ComboBox>
    
    
        </div>
        </form>
    </body>
    </html>
  2. #2
    Hi,

    The ComboBox values are int, but there are strings passed to the SetValue method.

    You can use ={}.
    cbb.SetValue("={0}");
    Then there will be an int value.

    Also you should wrap the Page_Load code in the
    !X.IsAjaxRequest
    condition.

    Example
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!X.IsAjaxRequest)
        {
            storeCbb.DataSource = new object[]
            {
                new object[] { 0, "John" },
                new object[] { 1, "Dermot" }
            };
            storeCbb.DataBind();
        }
    }
  3. #3
    Thank you. It's working with that change

Similar Threads

  1. [CLOSED] Change Listener has different behavior in version 2.x than in 1.x
    By MacGarnicle in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 29, 2012, 2:47 PM
  2. Replies: 1
    Last Post: Feb 10, 2011, 8:27 AM
  3. [CLOSED] [1.0] Change in radio button behavior - inputvalue
    By betamax in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 18, 2010, 4:02 PM
  4. Replies: 5
    Last Post: Mar 30, 2010, 8:32 PM
  5. [CLOSED] Combobox behavior on lookup
    By iansriley in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 30, 2009, 2:39 PM

Tags for this Thread

Posting Permissions