2013-04-22 4 views
1

FormPanel (ComboBox가 있음)과 TreePanel (기본 루트 노드 있음)이 있고 ViewState가 열려 있습니다.Ext.net의 ComboBox에 약간의 문제가 있습니다.

GET에서 값을 ComboBox로 설정합니다.

TreePanel의 Store가 POSTPackel의 Store가 클라이언트에 렌더링 된 FormPane 앞에 POST 요청 (저장 읽기)을 보내면이 POST 요청에서 fromdata에 FormPane에 대한 정보가 없습니다. POST 요청의 ViewState에서 ComboBox.Value 복구에

하지만 ComboBoxBase.LoadPostData에서() Ext.Net GET formdata에서 가치와 전제 조건

이 ComboBoxBase.LoadPostData() 코드

의없이 ComboBox.Value을 포함
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; 
    } 

봐 줄에서 5 11, 왜이 질문

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(); 

샘플처럼 변경하지

페이지 파일

<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 파일

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); 

     GP = new GridPanel(); 
     GP.ID = "GP"; 
     GP.Title = "GP"; 
     GP.Region = Region.East; 

     GP.Listeners.BeforeRender.Handler = "App.Store1.reload()"; 

     BTN = new Button(); 
     BTN.ID = "BTN"; 
     BTN.Text = "click"; 
     BTN.Icon = Icon.ArrowJoin; 
     BTN.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(Click); 

     TB = new Toolbar(); 
     TB.Items.Add(BTN); 

     GP.TopBar.Add(TB); 

     Store1 = new Store(); 
     Store1.ID = "Store1"; 
     Store1.ReadData += new Store.AjaxReadDataEventHandler(WebFormTest_ReadData); 

     Model1 = new Model(); 
     Model1.ID = "Model1"; 

     Store1.Model.Add(Model1); 

     GP.Store.Add(Store1); 

     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(GP); 

     VP.Items.Add(TP); 

     if (!X.IsAjaxRequest) 
     { 
      CB.Value = "2"; 
      TF.Value = "TEXT"; 
     } 
     base.OnInitComplete(e); 
    } 

    FormPanel FP; 
    TextField TF; 
    ComboBox CB; 
    GridPanel GP; 
    Button BTN; 
    Toolbar TB; 
    Store Store1; 
    Model Model1; 
    TreePanel TP; 
    TreeStore Store2; 
    protected override void CreateChildControls() 
    { 


     base.CreateChildControls(); 
    } 


    void Store2_ReadData(object sender, NodeLoadEventArgs e) 
    { 

    } 


    protected void Page_Load(object sender, EventArgs e) 
    { 
     //if (!X.IsAjaxRequest) 
     //{ 
     // this.Store1.DataSource = this.Data; 
     // this.Store1.DataBind(); 

     //} 

    } 



    protected void Refresh(object sender, DirectEventArgs e) 
    { 

    } 

    bool flag = false; 
    protected void Click(object sender, DirectEventArgs e) 
    { 
     GP.GetStore().Reload(); 
     flag = true; 
    } 

    protected override void OnPreRender(EventArgs e) 
    { 
     if (flag) 
     { 
      TF.Value = "asdasd"; 
     } 
     base.OnPreRender(e); 
    } 

    protected void WebFormTest_ReadData(object sender, StoreReadDataEventArgs e) 
    { 

    } 

    private object[] Data 
    { 
     get 
     { 
      return new object[] 
     { 
      new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am" }, 
     }; 
     } 
    } 
} 

우리는 SVN 트렁크에 변화를 저지른 Ext.net Forums

+0

보고서 주셔서 감사합니다. 우리는이 문제를 해결하기 위해 노력하고 있습니다. –

답변

0

에 당신은 또한 토론 할 수 있습니다. 다음 릴리스 (v2.3)로 이동합니다.

변경 사항은 귀하의 것과 유사하지만 RawValue도 변경하지 않기로 결정했습니다. 이 보고서와 제안 된 문제에 대해 감사드립니다.

수정 (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(); 
관련 문제