Jul 18, 2011, 10:31 AM
[CLOSED] Refresh ComboBox after changing Store
Hi,
How would I refresh the items in a ComboBox after I have changed the store of that ComboBox?
Example:
How would I refresh the items in a ComboBox after I have changed the store of that ComboBox?
Example:
<%@ Page Language="C#" %><%@ Import Namespace="System.Collections.Generic" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
List<object> list = new List<object>
{
new {Text = "1", Value = 1},
new {Text = "2", Value = 2},
new {Text = "3", Value = 3}
};
Store1.DataSource = list;
Store1.DataBind();
List<object> list2 = new List<object>
{
new {Text = "4", Value = 4},
new {Text = "5", Value = 5},
new {Text = "6", Value = 6}
};
Store2.DataSource = list2;
Store2.DataBind();
}
}
</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 id="Head1" runat="server">
<title></title>
<script type="text/javascript">
var buttonClick = function () {
ComboBox1.store = Store2;
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Store runat="server" ID="Store1">
<Reader>
<ext:JsonReader IDProperty="Value">
<Fields>
<ext:RecordField Name="Text" />
<ext:RecordField Name="Value" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:Store runat="server" ID="Store2">
<Reader>
<ext:JsonReader IDProperty="Value">
<Fields>
<ext:RecordField Name="Text" />
<ext:RecordField Name="Value" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:ComboBox ID="ComboBox1" runat="server" StoreID="Store1" DisplayField="Text" ValueField="Value" />
<ext:Button runat="server" Text="Change Store">
<Listeners>
<Click Fn="buttonClick" />
</Listeners>
</ext:Button>
</form>
</body>
</html>
The button should change the items in the ComboBox to be 4, 5 & 6. It changes the store successfully but the items in the ComboBox don't change.
Last edited by Daniil; Oct 04, 2013 at 5:39 AM.
Reason: [CLOSED]