[FIXED] [2.3] Some trouble with ComboBox

  1. #1

    [FIXED] [2.3] Some trouble with ComboBox

    Hello,everyone.
    I have a Page which a FormPanel(there's a ComboBox in it) and a TreePanel(has a default root node) in it and open ViewState.

    Click image for larger version. 

Name:	1.png 
Views:	34 
Size:	4.5 KB 
ID:	6142
    I set a value to ComboBox in GET.

    Click image for larger version. 

Name:	2.png 
Views:	31 
Size:	3.1 KB 
ID:	6143
    When i GET the page the TreePanel's Store send a POST request(store read) before FormPane rendered in client,in this POST request the fromdata has no info about FormPane.

    Click image for larger version. 

Name:	3.png 
Views:	31 
Size:	19.7 KB 
ID:	6144
    Click image for larger version. 

Name:	4.jpg 
Views:	24 
Size:	74.7 KB 
ID:	6145
    in the POST request recover the ComboBox.Value from ViewState,but in ComboBoxBase.LoadPostData() Ext.Net get value from formdata and cover ComboBox.Value without precondition

    Click image for larger version. 

Name:	5.png 
Views:	30 
Size:	36.2 KB 
ID:	6146
    it's ComboBoxBase.LoadPostData() code

     protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
            {
                this.HasLoadPostData = true;
    
                string text = postCollection[this.UniqueName];
                string state = postCollection[this.ValueHiddenName.IsNotEmpty() ? this.ValueHiddenName : ("_" + this.UniqueName + "_state")];
    
                this.SuspendScripting();
                this.RawValue = text;
                this.Value = text;
                this.ResumeScripting();
    
                if (state == null && text == null)
                {
                    return false;
                }
    
                if (!this.EmptyText.Equals(text) && text.IsNotEmpty())
                {
                    List<ListItem> items = null;
                    if (this.SimpleSubmit)
                    {
                        var array = state.Split(new char[] { ',' });
                        items = new List<ListItem>(array.Length);
                        foreach (var item in array)
                        {
                            items.Add(new ListItem(item));
                        }                    
                    }
                    else if(state.IsNotEmpty())
                    {
                        items = ComboBoxBase.ParseSelectedItems(state);
                    }
    
                    bool fireEvent = false;
    
                    if (items == null)
                    {
                        items = new List<ListItem> 
                        { 
                            new ListItem(text)
                        };                    
                        
                        /*fireEvent = this.SelectedItems.Count > 0;
                        this.SelectedItems.Clear();
                        return fireEvent;
                        */
                    }
    
                    foreach (var item in items)
                    {
                        if (!this.SelectedItems.Contains(item))
                        {
                            fireEvent = true;
                            break;
                        }
                    }
    
                    this.SelectedItems.Clear();
                    this.SelectedItems.AddRange(items);
    
                    return fireEvent;
                }
                else
                {
                    if (this.EmptyText.Equals(text) && this.SelectedItems.Count > 0)
                    {
                        this.SelectedItems.Clear();
    
                        return true;
                    }
                }
                
                return false;
            }
    Look at Line 5 to 11,why not change like this

     string text = postCollection[this.UniqueName];
                 string state = postCollection[this.ValueHiddenName.IsNotEmpty() ? this.ValueHiddenName : ("_" + this.UniqueName + "_state")];
    
                this.SuspendScripting();
                this.RawValue = text;
                this.ResumeScripting();
    
                if (state == null && text == null)
                {
                    return false;
                }
    
                this.SuspendScripting();
                this.Value = text;
                this.ResumeScripting();
    Sample for this question

    • page file
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head runat="server">
          <title></title>
      </head>
      <body>
          <ext:ResourceManager ID="ResourceManager1" runat="server" DisableViewState="false"
              AjaxViewStateMode="Enabled"  ViewStateMode="Enabled"/>
          <form id="form1" runat="server">
          <ext:Viewport runat="server" ID="VP">
          </ext:Viewport>
      
          </form>
      </body>
      </html>
    • cs file
      public partial class WebFormTest : System.Web.UI.Page
          {
              protected override void OnInitComplete(EventArgs e)
              {
                  FP = new FormPanel();
                  FP.ID = "FP";
                  FP.Title = "FP";
                  FP.Region = Region.Center;
      
                  TF = new TextField();
                  TF.ID = "TF";
                  TF.FieldLabel = "TF";
      
                  CB = new ComboBox();
                  CB.ID = "CB";
                  CB.FieldLabel = "CB";
                  CB.Items.Clear();
                  CB.Items.Add(new ListItem("one", "1"));
                  CB.Items.Add(new ListItem("two", "2"));
      
                  Button test = new Button() { ID = "testbtn", Text = "test" };
                  test.Listeners.Click.Handler = "App.Store2.load()";
                  FP.TopBar.Add(new Toolbar() { Items = { test } });
      
                  FP.Items.Add(TF);
                  FP.Items.Add(CB);
      
                  TP = new TreePanel();
                  TP.ID = "TP";
                  TP.Title = "TP";
                  TP.Region = Region.East;
                  TP.RootVisible = false;
                  TP.Root.Add(new Node() { NodeID = "test", Text = "test" });
      
                  Store2 = new TreeStore();
                  Store2.ID = "Store2";
                  Store2.ReadData += new TreeStoreBase.ReadDataEventHandler(Store2_ReadData);
      
                  TP.Store.Add(Store2);
      
                  VP.Items.Add(FP);
      
                  VP.Items.Add(TP);
      
                  if (!X.IsAjaxRequest)
                  {
                      CB.Value = "2";
                      TF.Value = "TEXT";
                  }
                  base.OnInitComplete(e);
              }
      
              FormPanel FP;
              TextField TF;
              ComboBox CB;
              TreePanel TP;
              TreeStore Store2;
      
              void Store2_ReadData(object sender, NodeLoadEventArgs e)
              {
      
              }
      
      
              protected void Page_Load(object sender, EventArgs e)
              {
      
              }
      
      
              protected void WebFormTest_ReadData(object sender, StoreReadDataEventArgs e)
              {
      
              }
      
      
          }
    Last edited by Daniil; May 07, 2013 at 3:30 AM. Reason: [FIXED] [2.3]
  2. #2
    Hi @Soy,

    Please clarify what are the steps to reproduce the issue using your test case?

    Also I am not sure what you are expecting and what you are actually getting instead. Needs some demonstration.
  3. #3
    hi,@Daniil
    I have update the thread~!
  4. #4
    Thank you. I think I understand the problem now.

    Probably, we should make the change. I will discuss it with the colleagues.
  5. #5
    Daniil,thanks for reply ,I will waiting for the result of the discussion.
  6. #6
    We committed the change to the SVN trunk. It will go to the next release.

    The change is similar to your one, but we decided not to change RawValue as well. Thank you for the report and suggested fix.

    Fix (ComboBoxBase LoadPostData)
    protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
    {
        this.HasLoadPostData = true;
    
        string text = postCollection[this.UniqueName];
        string state = postCollection[this.ValueHiddenName.IsNotEmpty() ? this.ValueHiddenName : ("_" + this.UniqueName + "_state")];
    
        if (state == null && text == null)
        {
            return false;
        }
    
        this.SuspendScripting();
        this.RawValue = text;
        this.Value = text;
        this.ResumeScripting();
        // the same
    Last edited by Daniil; May 07, 2013 at 3:36 AM.
  7. #7
    Thanks,@Daniil.

Similar Threads

  1. Trouble in deployment
    By fosteliss in forum 2.x Help
    Replies: 6
    Last Post: Dec 13, 2012, 8:35 PM
  2. Trouble with icons using razor and mvc 4
    By gdog_5021 in forum 2.x Help
    Replies: 0
    Last Post: Oct 18, 2012, 12:18 AM
  3. MVC Store Trouble
    By Doug.Morrow in forum 2.x Help
    Replies: 1
    Last Post: Aug 02, 2012, 10:17 PM
  4. [CLOSED] Date Trouble
    By adelaney in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 28, 2012, 12:59 PM
  5. [CLOSED] Trouble when updaing SVN (Ext Net 1.0)
    By vedagopal2004 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 23, 2010, 4:32 AM

Posting Permissions