[CLOSED] Combo value problem

  1. #1

    [CLOSED] Combo value problem

    Hi..

    i have kept 1 combo box,empty text field,button and another text field to display the combo value..

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="grid.WebForm1" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!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>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ScriptManager runat="server">
        </ext:ScriptManager>
        <ext:ComboBox ID="cmbCommodityName" runat="server" Width="165" FieldLabel="Commodity Name">
        <Items>
        <ext:ListItem Text="AAA" Value="0" />
        <ext:ListItem Text="BBB" Value="1" />
        <ext:ListItem Text="CCC" Value="2" />
        <ext:ListItem Text="DDD" Value="3" />
        <ext:ListItem Text="EEE" Value="4" />
        <ext:ListItem Text="FFF" Value="5" />
        <ext:ListItem Text="GGG" Value="6" />
        <ext:ListItem Text="HHH" Value="7" />
        </Items> 
        <SelectedItem Text="AAA" Value="0" />    
        </ext:ComboBox>
        <ext:TextField runat="server" />
    
        <ext:Button ID="btnSave" Text="Save" runat="server" >
        <AjaxEvents>
        <Click OnEvent="btnSave_Click" />
        </AjaxEvents>
        </ext:Button>
        <ext:TextField ID="txtCommodity" runat="server" FieldLabel="Commodity Value" />
        </form>
    </body>
    </html>
    
    
      protected void btnSave_Click(object sender, AjaxEventArgs e)
            {
                txtCommodity.Text = cmbCommodityName.SelectedItem.Value;
            }

    im displaying the value of commodity names in commodity value text field...
    if user selcet commodity name from combo and clicks on button it will display the commodity value in commodity value text field...

    it is workig fine if user selects commodity name and clicks on button..see picture(WithoutEdit.jpg )

    if user try to edit combo box(EditAndPressTab.jpg) and press tab it will display previously selected combo item in combo box and then clicks on button it will not display value in commodity value text field..instead of value it is displaying text..(afterEdit.jpg)

    how to solve this problem?
    Attached Thumbnails Click image for larger version. 

Name:	EditAndPressTab.JPG 
Views:	108 
Size:	3.8 KB 
ID:	2286   Click image for larger version. 

Name:	afterEdit.JPG 
Views:	90 
Size:	3.3 KB 
ID:	2287   Click image for larger version. 

Name:	Without Edit.JPG 
Views:	94 
Size:	3.0 KB 
ID:	2288  
    Last edited by geoffrey.mcgill; Feb 09, 2011 at 5:19 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Yes, there is an issue.

    What about to avoid editing of ComboBox?
    <ext:ComboBox ... Editable="false">
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    Yes, there is an issue.

    What about to avoid editing of ComboBox?
    <ext:ComboBox ... Editable="false">
    i'll not keep editable=false, i want to type and search the items
  4. #4
    Ok, then please add the following fix into <head> of page.

    Fix
    <ext:ScriptContainer runat="server" />
    
    <script type="text/javascript">
        Ext.form.ComboBox.override({
            beforeBlur : function () {
                Ext.form.ComboBox.superclass.beforeBlur.call(this);
                var t = this.getEl().dom.value.trim(), 
                    v = this.getValue();
                
                this.changed = false;
                if (this.oldValue !== v || (t !== this.oldText && t !== this.emptyText)) {
                    if (!Ext.isEmpty(this.selValue) && this.selText != t && this.selValue == this.getValue()) {
                        this.hiddenField.value = "";
                    }
    
                    var val = this.el.dom.value,
                        r = this.findRecordByText(this.displayField, val);
    
                    this.setValue(!Ext.isEmpty(r) ? r.data[this.valueField] : this.forceSelection ? v : val);
    
                    this.getSelectedIndexField().setValue(this.getSelectedIndex());
                    this.changed = true;
                }
            }
        });
    </script>

    Full example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <script runat="server">
        protected void btnSave_Click(object sender, AjaxEventArgs e)
        {
            this.txtCommodity.Text = this.cmbCommodityName.SelectedItem.Value;
        }
    </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>
        <ext:ScriptContainer runat="server" />
    
        <script type="text/javascript">
            Ext.form.ComboBox.override({
                beforeBlur : function () {
                    Ext.form.ComboBox.superclass.beforeBlur.call(this);
                    var t = this.getEl().dom.value.trim(), 
                        v = this.getValue();
                    
                    this.changed = false;
                    if (this.oldValue !== v || (t !== this.oldText && t !== this.emptyText)) {
                        if (!Ext.isEmpty(this.selValue) && this.selText != t && this.selValue == this.getValue()) {
                            this.hiddenField.value = "";
                        }
    
                        var val = this.el.dom.value,
                            r = this.findRecordByText(this.displayField, val);
    
                        this.setValue(!Ext.isEmpty(r) ? r.data[this.valueField] : this.forceSelection ? v : val);
    
                        this.getSelectedIndexField().setValue(this.getSelectedIndex());
                        this.changed = true;
                    }
                }
            });
        </script>
    
    </head>
    <body>
        <form runat="server">
        <ext:ScriptManager runat="server" />
        <ext:ComboBox ID="cmbCommodityName" runat="server" FieldLabel="Commodity Name">
            <Items>
                <ext:ListItem Text="AAA" Value="0" />
                <ext:ListItem Text="BBB" Value="1" />
                <ext:ListItem Text="CCC" Value="2" />
                <ext:ListItem Text="DDD" Value="3" />
                <ext:ListItem Text="EEE" Value="4" />
                <ext:ListItem Text="FFF" Value="5" />
                <ext:ListItem Text="GGG" Value="6" />
                <ext:ListItem Text="HHH" Value="7" />
            </Items>
            <SelectedItem Value="0" />
        </ext:ComboBox>
        <ext:Button Text="Save" runat="server">
            <AjaxEvents>
                <Click OnEvent="btnSave_Click" />
            </AjaxEvents>
        </ext:Button>
        <ext:TextField ID="txtCommodity" runat="server" FieldLabel="Commodity Value" />
        </form>
    </body>
    </html>
  5. #5
    Quote Originally Posted by Daniil View Post
    Ok, then please add the following fix into <head> of page.

    Fix
    <ext:ScriptContainer runat="server" />
    
    <script type="text/javascript">
        Ext.form.ComboBox.override({
            beforeBlur : function () {
                Ext.form.ComboBox.superclass.beforeBlur.call(this);
                var t = this.getEl().dom.value.trim(), 
                    v = this.getValue();
                
                this.changed = false;
                if (this.oldValue !== v || (t !== this.oldText && t !== this.emptyText)) {
                    if (!Ext.isEmpty(this.selValue) && this.selText != t && this.selValue == this.getValue()) {
                        this.hiddenField.value = "";
                    }
    
                    var val = this.el.dom.value,
                        r = this.findRecordByText(this.displayField, val);
    
                    this.setValue(!Ext.isEmpty(r) ? r.data[this.valueField] : this.forceSelection ? v : val);
    
                    this.getSelectedIndexField().setValue(this.getSelectedIndex());
                    this.changed = true;
                }
            }
        });
    </script>

    Full example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <script runat="server">
        protected void btnSave_Click(object sender, AjaxEventArgs e)
        {
            this.txtCommodity.Text = this.cmbCommodityName.SelectedItem.Value;
        }
    </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>
        <ext:ScriptContainer runat="server" />
    
        <script type="text/javascript">
            Ext.form.ComboBox.override({
                beforeBlur : function () {
                    Ext.form.ComboBox.superclass.beforeBlur.call(this);
                    var t = this.getEl().dom.value.trim(), 
                        v = this.getValue();
                    
                    this.changed = false;
                    if (this.oldValue !== v || (t !== this.oldText && t !== this.emptyText)) {
                        if (!Ext.isEmpty(this.selValue) && this.selText != t && this.selValue == this.getValue()) {
                            this.hiddenField.value = "";
                        }
    
                        var val = this.el.dom.value,
                            r = this.findRecordByText(this.displayField, val);
    
                        this.setValue(!Ext.isEmpty(r) ? r.data[this.valueField] : this.forceSelection ? v : val);
    
                        this.getSelectedIndexField().setValue(this.getSelectedIndex());
                        this.changed = true;
                    }
                }
            });
        </script>
    
    </head>
    <body>
        <form runat="server">
        <ext:ScriptManager runat="server" />
        <ext:ComboBox ID="cmbCommodityName" runat="server" FieldLabel="Commodity Name">
            <Items>
                <ext:ListItem Text="AAA" Value="0" />
                <ext:ListItem Text="BBB" Value="1" />
                <ext:ListItem Text="CCC" Value="2" />
                <ext:ListItem Text="DDD" Value="3" />
                <ext:ListItem Text="EEE" Value="4" />
                <ext:ListItem Text="FFF" Value="5" />
                <ext:ListItem Text="GGG" Value="6" />
                <ext:ListItem Text="HHH" Value="7" />
            </Items>
            <SelectedItem Value="0" />
        </ext:ComboBox>
        <ext:Button Text="Save" runat="server">
            <AjaxEvents>
                <Click OnEvent="btnSave_Click" />
            </AjaxEvents>
        </ext:Button>
        <ext:TextField ID="txtCommodity" runat="server" FieldLabel="Commodity Value" />
        </form>
    </body>
    </html>

    Hi Daniil,,its working fine Thank you.

    But is there any Alternative way like Set any property to comboBox like that..
  6. #6
    Unfortunately, no, there is no alternative way to solve it.
  7. #7
    Please note that you could update to 0.8.2 or 0.8.3 version. This bug is fixed there.

Similar Threads

  1. [CLOSED] Problem with related combo
    By John_Writers in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 25, 2011, 2:57 PM
  2. [CLOSED] Combo Box Pre-Selection Problem
    By IanPearce in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jun 07, 2011, 3:43 PM
  3. [CLOSED] combo box problem
    By Vasudhaika in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 16, 2011, 1:03 PM
  4. [CLOSED] Combo render problem
    By pdcase in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Aug 31, 2010, 7:53 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