[CLOSED] [1.0] ComboBox.SelectedItem.Value

  1. #1

    [CLOSED] [1.0] ComboBox.SelectedItem.Value

    Hi,

    In the upgrade from Ext.NET RC1 to Final Version 1.0.0 we found that getting the value of the EmptyText for a ComboBox, using ComboBox.SelectedItem.Value, changed from returning "" (string.Empty) to null value instead.

    This was a breaking change for us, which we hadn't anticipated. I was assured that there would be no breaking changed in a reply to my post here http://forums.ext.net/showthread.php...ll=1#post60161

    Why was this not shared? I can not see it in the CHANGELOG?
    Last edited by Daniil; Jul 16, 2011 at 9:30 AM. Reason: [CLOSED]
  2. #2
    Hi,

    I agree with you. We will consider to include that aspect into CHANGLELOG.

    Example Ext.Net 1

    <%@ 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", "item1" },
                    new object[] { "2", "item2" },
                    new object[] { "3", "item3" }
                };
                store.DataBind();
            }
        }
    
        protected void GetValue(object sender, DirectEventArgs e)
        {
            string value;
            if (this.ComboBox1.SelectedItem.Value == null)
            {
                value = "null";
            }
            else if (this.ComboBox1.SelectedItem.Value.Equals(""))
            {
                value = "Empty";
            }
            else
            {
                value = this.ComboBox1.SelectedItem.Value;
            }
            X.Msg.Alert(".Value", value).Show();
        }
    </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 runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:ComboBox ID="ComboBox1" runat="server">
                <Store>
                    <ext:Store runat="server">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="value" />
                                    <ext:RecordField Name="text" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
            </ext:ComboBox>
            <ext:Button runat="server" Text="Get .Value" OnDirectClick="GetValue" />
        </form>
    </body>
    </html>
    Example Coolite 0.8.x

    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Ext.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[] 
                { 
                    new object[] { "1", "item1" },
                    new object[] { "2", "item2" },
                    new object[] { "3", "item3" }
                };
                this.Store1.DataBind();
            }
        }
    
        protected void GetValue(object sender, AjaxEventArgs e)
        {
            string value;
            if (this.ComboBox1.SelectedItem.Value == null)
            {
                value = "null";
            }
            else if (this.ComboBox1.SelectedItem.Value.Equals(""))
            {
                value = "Empty";
            }
            else
            {
                value = this.ComboBox1.SelectedItem.Value;
            }
            Ext.Msg.Alert(".Value", value).Show();
        }
    </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 runat="server">
        <title>Coolite 0.8.x Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ScriptManager runat="server" />
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="value" />
                            <ext:RecordField Name="text" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
            <ext:ComboBox ID="ComboBox1" runat="server" StoreID="Store1" />
            <ext:Button runat="server" Text="Get .Value" OnDirectClick="GetValue">
                <AjaxEvents>
                    <Click OnEvent="GetValue" />
                </AjaxEvents>
            </ext:Button>
        </form>
    </body>
    </html>
  3. #3
    Hi,

    Thanks for pointing out the missing CHANGELOG item.

    I'm investigating why this default value was changed.

    We'll certainly add the item to the CHANGELOG.
    Geoffrey McGill
    Founder
  4. #4
    Thanks for the quick response!

    If this is not intentional, could we have a fix for it?
  5. #5
    Hello again,

    We have a release approaching very soon, this problem impacts a lot of our code - so I am going to amend your source code for our release. If you can assist me, that would be much appreciated.

    Once I've found and amended the code to resolve the above problem, are there any particular steps I need to follow to do a build?

    Thanks.
  6. #6
    We are going to add this item to CHANGELOG.

    So, we won't change it in SVN.

    Can you just use .IsNullOrEmpty() method?
  7. #7
    We have 450 pages in application and on average each page have about 8-10 combo controls, you mean to go through all these pages and put IsNullOrEmpty() - that's not a solution.

    We upgraded because we were told that there are no breaking changes see this http://forums.ext.net/showthread.php...ll=1#post60161

    What we need from you is help on fixing this, as premium member we can download source code from svn repository but if you can point out what is causing this we can fix it!

    It is very very urgent!!!
    Last edited by geoffrey.mcgill; Jul 13, 2011 at 12:59 PM.
  8. #8
    Hi,

    I believe the bug fix (which caused a breaking change in your app) was related to the following SVN commit.

    Revision: 3371Author: geoffrey.mcgill
    Date: 11:28:46 AM, Friday, December 10, 2010
    Message:
    [FIX] Fixed issue where ComboBox .value config item was being rendered even if it had not been set.
    ----
    Modified : /trunk/Ext.Net/Ext/Form/ComboBoxBaseSingle.cs
    Modified : /trunk/Ext.Net/Ext/Form/ListItem.cs
    Modified : /trunk/Ext.Net/Factory/Config/ListItemConfig.cs
    Modified : /trunk/Ext.Net/Factory/ext.net.meta.xml

    Here's the unified diff:

    Index: ComboBoxBaseSingle.cs===================================================================
    --- ComboBoxBaseSingle.cs    (revision 3370)
    +++ ComboBoxBaseSingle.cs    (revision 3371)
    @@ -20,7 +20,7 @@
             /// <summary>
             /// 
             /// </summary>
    -        [DefaultValue("")]
    +        [DefaultValue(null)]
             [Browsable(false)]
             [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
             [Description("")]
    @@ -32,7 +32,7 @@
                 }
                 set
                 {
    -                this.SelectedItem.Value = value == null ? "" : value.ToString();
    +                this.SelectedItem.Value = (string)value ?? null;
                 }
             }
    As noted in the "Modified" files list, the same [DefaultValue] related change was made to /trunk/Ext.Net/Ext/Form/ListItem.cs. While you're in there, you should revert the ListItem.cs (and ListItemConfig.cs) change as well as ComboBoxBaseSingle.cs.

    Reverting the .xml file should not be required.

    The revisions to the .cs files have been made, perform a "Rebuild Solution" to generate new .dlls.

    Hope this helps.
    Last edited by geoffrey.mcgill; Jul 13, 2011 at 1:39 PM.
    Geoffrey McGill
    Founder
  9. #9
    Hi sadaf,

    Did you get this all working as per you requirements?
    Geoffrey McGill
    Founder
  10. #10
    Thanks Geoffery - we managed to fix it with your help. again thanks for a prompt help!

Similar Threads

  1. [CLOSED] V2.0 ComboBox SelectedItem
    By Aurelio in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Apr 02, 2012, 1:28 PM
  2. [CLOSED] Combobox SelectedItem
    By Sevilay Tanış in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 13, 2012, 2:02 PM
  3. ComboBox and selectedItem.value
    By cwolcott in forum 1.x Help
    Replies: 3
    Last Post: Feb 01, 2012, 7:48 AM
  4. Replies: 4
    Last Post: Nov 30, 2011, 5:25 AM
  5. Replies: 4
    Last Post: Feb 02, 2010, 4:08 PM

Posting Permissions