[CLOSED] Clear combobox list items in the code behind

  1. #1

    [CLOSED] Clear combobox list items in the code behind

    I made a search in the fórum, but I didn't find any help.

    How can I clear combobox list items in the code behind during ajax request?

    I have to clear old items and add new items to the list.
    I'm not using store.

    designer code
    <ext:Button runat="server" ID="MyButton" Text="Test Combo" X="150" Y="180">
                            <DirectEvents>
                                <Click OnEvent="MyButtonClick">
                                </Click>
                            </DirectEvents>
                        </ext:Button>
    
    
    <ext:ComboBox runat="server" ID="MyCombo" FieldLabel="Ano" X="0" Y="180" AllowBlank="false"
                            Width="70" />
    code behind
    protected void MyButtonClick(object sender, DirectEventArgs e)
            {
                MyCombo.Items.Clear();//not work
                MyCombo.AddScript(MyCombo.ClientID + ".store.data.clear();");//not work
                MyCombo.Clear();//not work
    
                for (int i = 0; i < 20; i++)
                    MyCombo.AddItem("Pos " + i.ToString(), i.ToString());
            }
    Last edited by Daniil; May 24, 2011 at 3:18 PM. Reason: [CLOSED]
  2. #2
    Hi,

    MyCombo.RemoveAll() should help.
  3. #3
    Sorry. But I didn't find removeAll().

  4. #4
    Hi,

    It is store's method, please use
    MyCombo.GetStore().RemoveAll();
  5. #5
    Hi,

    Thanks. :)
    MyCombo.GetStore().RemoveAll()
    solved for me

Similar Threads

  1. Replies: 0
    Last Post: Jun 08, 2012, 11:49 AM
  2. combobox list items not comming in left align
    By Nagaraju in forum 1.x Help
    Replies: 3
    Last Post: Dec 15, 2011, 3:27 PM
  3. Combobox items clear?
    By Nagaraju in forum 1.x Help
    Replies: 2
    Last Post: Oct 06, 2011, 2:34 PM
  4. Combobox loses its list of items
    By PeterParsonage in forum 1.x Help
    Replies: 1
    Last Post: Feb 10, 2011, 10:46 PM
  5. Combobox List Items Class
    By Tbaseflug in forum 1.x Help
    Replies: 6
    Last Post: Dec 10, 2010, 7:26 AM

Tags for this Thread

Posting Permissions