PDA

View Full Version : TabPanel and ComboBox



Timothy
Mar 31, 2009, 5:31 PM
Hello,

The following example demonstrates that the SetValue of the ComboBox does not appear to be working:

Example.aspx:


<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void Button1_Click(object sender, EventArgs e)
{
ComboBox1.SetValue(1);

TabPanel1.SetActiveTab(Tab2);
}

protected void Store1_RefreshData(object sender, StoreRefreshDataEventArgs e)
{
Store1.DataSource = new object[] {
new object[] { 1, "Timothy" },
new object[] { 2, "Geoffrey" }
};
Store1.DataBind();
}

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" EnablePartialRendering="True" />
<ext:ScriptManager runat="server" AjaxViewStateMode="Include" EnableViewState="true" Theme="Gray" />
<ext:TabPanel ID="TabPanel1" runat="server" Border="false">
<Tabs>
<ext:Tab ID="Tab1" runat="server" AutoHeight="true" Title="Tab 1">
<Body>
<ext:Button ID="Button1" runat="server" AutoPostBack="true" &#111;nclick="Button1_Click" Text="Load ..." />
</Body>
</ext:Tab>
<ext:Tab ID="Tab2" runat="server" AutoHeight="true" Title="Tab 2">
<Body>
<ext:Store ID="Store1"
runat="server"
AutoLoad="true"
IgnoreExtraFields="true"
OnRefreshData="Store1_RefreshData">
<Proxy>
<ext:DataSourceProxy />
</Proxy>
<Reader>
<ext:ArrayReader ReaderID="Id">
<Fields>
<ext:RecordField Name="Id" Type="Auto" />
<ext:RecordField Name="DisplayName" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
<ext:ComboBox ID="ComboBox1"
runat="server"
StoreID="Store1"
DisplayField="DisplayName"
Editable="true"
EmptyText="----"
FireSelect&#111;nload="true"
ForceSelection="true"
Mode="Local"
Select&#111;nfocus="true"
TriggerAction="All"
TypeAhead="true"
ValueField="Id"
Width="255" />
</Body>
</ext:Tab>
</Tabs>
</ext:TabPanel>
</form>
</body>
</html>



Replication steps:

1. Load page
2. Switch to 2nd tab, notice --- and the items available
3. Switch back to 1st tab
4. Click Load ...
5. Notice it doesn't select Timothy

Side note, I also used SetValueAndFireSelect() which also didn't work.

Cheers,
Timothy

Vladimir
Mar 31, 2009, 5:51 PM
Hi Timothy,

SetValue method must be used during AjaxEvent only (because it must be called after Store data is loaded)
During postback you need use


ComboBox1.SelectedItem.Value = "1";



I understnad that it can confuse to use several function to set value. We will unify it soon

Timothy
Mar 31, 2009, 5:54 PM
Ooops, and here I was thinking I was doing it proper with the Set function ;)

Thanks for clearing that up vladimir.

Cheers,
Timothy