I've tried to do .Items.Clear() and then .Items.Add(...) for the items I'm trying to add, but it doesn't change the items. Is there something more I have to do to change ComboBox items during a DirectEvent?
Printable View
I've tried to do .Items.Clear() and then .Items.Add(...) for the items I'm trying to add, but it doesn't change the items. Is there something more I have to do to change ComboBox items during a DirectEvent?
I found this thread which shows how to clear the combobox, but I still need to see how to add items:
http://forums.ext.net/showthread.php...ut-using-store)
Hello!
Please look at this example.
Example
Code:<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Button_Click(object sender, DirectEventArgs e)
{
String record1 = "new Ext.data.Record({text:3, value:3})";
String record2 = "new Ext.data.Record({text:4, value:4})";
String records = "[" + record1 + "," + record2 + "]";
String script = ComboBox1.ClientID.ToString() + ".getStore().add(" + records + ");";
X.AddScript(script);
}
</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>Ext.Net Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" ScriptMode="Debug" />
<ext:ComboBox ID="ComboBox1" runat="server">
<Items>
<ext:ListItem Text="1" Value="1" />
<ext:ListItem Text="2" Value="2" />
</Items>
</ext:ComboBox>
<ext:Button runat="server" Text="Add items">
<DirectEvents>
<Click OnEvent="Button_Click" />
</DirectEvents>
</ext:Button>
</form>
</body>
</html>
Hi,
You can update Items via GetStore
Please see the following sample
Code:<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Button_Click(object sender, DirectEventArgs e)
{
ComboBox1.Items.Clear();
ComboBox1.Items.Add(new Ext.Net.ListItem("3", "3"));
ComboBox1.Items.Add(new Ext.Net.ListItem("4", "4"));
ComboBox1.GetStore().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 runat="server">
<title>Ext.Net Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" ScriptMode="Debug" />
<ext:ComboBox ID="ComboBox1" runat="server">
<Items>
<ext:ListItem Text="1" Value="1" />
<ext:ListItem Text="2" Value="2" />
</Items>
</ext:ComboBox>
<ext:Button runat="server" Text="Add items">
<DirectEvents>
<Click OnEvent="Button_Click" />
</DirectEvents>
</ext:Button>
</form>
</body>
</html>
Thanks. This worked.
hi
Is the ComboBox1.GetStore() new? Because it seems not available. I'm working with the public available 1.0b.
Hi,
Yes, it was added after the preview is released
Thanks, how do I update?
Hi,
Update from SVN is available for premium members only (http://www.ext.net/store/)
Ok just bought one :cool: