[CLOSED] Change ComboBox items during DirectEvent

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Change ComboBox items during DirectEvent

    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?
  2. #2
    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)
  3. #3
    Hello!

    Please look at this example.

    Example
    <%@ 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>
  4. #4
    Hi,

    You can update Items via GetStore
    Please see the following sample
    <%@ 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>
    Vladimir Shcheglov
    Sr. Developer
  5. #5
    Thanks. This worked.
  6. #6

    GetStore new?

    hi

    Is the ComboBox1.GetStore() new? Because it seems not available. I'm working with the public available 1.0b.
  7. #7
    Hi,

    Yes, it was added after the preview is released
    Vladimir Shcheglov
    Sr. Developer
  8. #8

    Update

    Thanks, how do I update?
  9. #9
    Hi,

    Update from SVN is available for premium members only (http://www.ext.net/store/)
    Vladimir Shcheglov
    Sr. Developer
  10. #10

    yes

    Ok just bought one :cool:
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Add items to FormPanel during a DirectEvent
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 27, 2012, 4:48 PM
  2. [CLOSED] Set MultiSelect selected items during DirectEvent
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Sep 20, 2010, 4:07 PM
  3. Directevent on ext:combobox change
    By Rupesh in forum 1.x Help
    Replies: 2
    Last Post: Sep 16, 2010, 1:47 PM
  4. [CLOSED] ComboBox with Change DirectEvent
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 03, 2010, 7:31 PM
  5. [CLOSED] How to add menu items in a DirectEvent
    By SFritsche in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 18, 2010, 11:01 AM

Posting Permissions