[CLOSED] Add items to a MultiSelect list in a AjaxEvent?

  1. #1

    [CLOSED] Add items to a MultiSelect list in a AjaxEvent?



    Hi
    I need to add items to a MultiSelect list in a AjaxEvent. How do I do that?

    Thanks

    /Mikael
  2. #2

    RE: [CLOSED] Add items to a MultiSelect list in a AjaxEvent?

    Hi,

    You should use Store and rebind it
  3. #3

    RE: [CLOSED] Add items to a MultiSelect list in a AjaxEvent?

    Hi,
    I have same issue can anyone help me out my problem is iam unable to add items to multi select from code behind file how can i do it
  4. #4

    RE: [CLOSED] Add items to a MultiSelect list in a AjaxEvent?



    Hi
    Try this

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!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 SetStoreMulti(object sender, AjaxEventArgs e)
        {
            ArrayList alStore = new ArrayList();
            alStore.Add(new object[] { "ID1", "Value 1" });
            alStore.Add(new object[] { "ID2", "Value 2" });        
            
            this.StoreTest.DataSource = alStore;
            this.StoreTest.DataBind();        
    
    
        }
        protected void ShowValues(object sender, AjaxEventArgs e)
        {
            string multi1 = e.ExtraParams["multi1"];
            Coolite.Ext.Web.ListItem[] items1 = JSON.Deserialize<Coolite.Ext.Web.ListItem[]>(multi1);
    
    
            StringBuilder sb = new StringBuilder();
            foreach (Coolite.Ext.Web.ListItem item in items1)
            {
                sb.AppendFormat("Value: {0}<br />", item.Value);
            }
            Ext.MessageBox.Alert("Values", sb.ToString()).Show();
        }    
        
    </script>
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ScriptManager ID="ScriptManager1" runat="server">
        </ext:ScriptManager>    
        
    
    
            <ext:Store ID="StoreTest" runat="server" >
                <Reader>            
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="Id" Type="String" />                        
                            <ext:RecordField Name="Text" Type="String" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store> 
            
            
            <ext:MultiSelect ID="msTest" StoreID="StoreTest" runat="server" ValueField="Id" DisplayField="Text" ></ext:MultiSelect>
            <ext:Button runat="server" Text="Set items" ID="btnSetItems">
                <AjaxEvents>
                    <Click OnEvent="SetStoreMulti"></Click>
                </AjaxEvents>
            </ext:Button>
            <ext:Button runat="server" Text="Show values" ID="btnShowValues">
                <AjaxEvents>
                    <Click OnEvent="ShowValues">
                        <ExtraParams>
                            <ext:Parameter Name="multi1" Value="Ext.encode(#{msTest}.getValues())" Mode="Raw" />
                        </ExtraParams>                
                    </Click>
                </AjaxEvents>
            </ext:Button>
            
        
    
        </form>
    </body>
    </html>
    /Mikael
  5. #5

    RE: [CLOSED] Add items to a MultiSelect list in a AjaxEvent?

    Thanks Mikale you have solved my problem,but i have another issue that is after populating the multiselect items are visible in very small width and its text is not visible but if place mouse on those items yhen we call feel the items but text is not visible any help please

Similar Threads

  1. Replies: 0
    Last Post: Jun 08, 2012, 11:49 AM
  2. Combobox loses its list of items
    By PeterParsonage in forum 1.x Help
    Replies: 1
    Last Post: Feb 10, 2011, 10:46 PM
  3. Combobox List Items Class
    By Tbaseflug in forum 1.x Help
    Replies: 6
    Last Post: Dec 10, 2010, 7:26 AM
  4. [CLOSED] multiselect and AjaxEvent
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 06, 2009, 5:37 AM
  5. Replies: 0
    Last Post: Jun 03, 2009, 5:30 PM

Posting Permissions