MultiCombo (Connected to Store) - cannot select items in list

Page 1 of 2 12 LastLast
  1. #1

    MultiCombo (Connected to Store) - cannot select items in list

    Hey again,

    I have a MultiCombo that is connected to a Store, and that Store is populated in Page_Load.

    The MultiCombo shows all entries, but I cannot select them. They are "unclickable", nothing happens. I dont understand why. Anyone know? =)

    Code:

    protected void Page_Load(object sender, EventArgs e)
            {
              List<object> asd = new List<object>();
                
    
                Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
                foreach (Assembly assembly in asms)
                {
                    Type[] typeArray = assembly.GetTypes();
                    foreach (Type type in typeArray)
                    {
                        if (type.IsSubclassOf(typeof(MyNiceType)))
                        {
                            asd.Add(new object[] { type.ToString(), type.Name, type });
                        }
                    }
                }
    
                Store_LoginChannels.DataSource = asd;
                Store_LoginChannels.DataBind();
             }
    The MultiCombo looks like this:

    <ext:MultiCombo ID="MultiCombo_allowedLoginChannels" runat="server" SelectionMode="All" FieldLabel="Log in through" Width="175" StoreID="Store_LoginChannels"
                    DisplayField="typeName"
                    ValueField="typeObject"
                    EmptyText="Choose">
                </ext:MultiCombo>
    and the Store:

    <ext:Store ID="Store_LoginChannels" runat="server">
            <Reader>
                <ext:ArrayReader>
                    <Fields>
                        <ext:RecordField Name="typeStringId" />
                        <ext:RecordField Name="typeName" />
                        <ext:RecordField Name="typeObject" />
                    </Fields>
                </ext:ArrayReader>
            </Reader>
        </ext:Store>
  2. #2
    Hi,

    I can't see the problem.

    Please post a full sample, like the following one.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.ComboBox1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "1", "item1" },
                    new object[] { "2", "item2" },
                    new object[] { "3", "item3" }
                };
                store.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" />
        <ext:MultiCombo ID="ComboBox1" runat="server">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="value" />
                                <ext:RecordField Name="text" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
        </ext:MultiCombo>
        </form>
    </body>
    </html>
  3. #3
    Hi,
    yes I cannot see the problem either and examples in examples.ext.net works fine. The relevant code was posted above, but here is the full code from Users.asp.*.

    Regards


    Users.aspx (page on which the Add Users-button is located that brings up a Window with a form. On that form the MultiSelect exists):



    <%@ Page Title="" Language="C#" MasterPageFile="~/Secure/Views/View.Master" AutoEventWireup="true" CodeBehind="Users.aspx.cs" Inherits="WebApplicationExtNetTest.Secure.Views.Users" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <style type="text/css">
            .list-item {
                font:normal 11px tahoma, arial, helvetica, sans-serif;
                padding:3px 10px 3px 10px;
                border:1px solid #fff;
                border-bottom:1px solid #eeeeee;
                white-space:normal;
                color:#555;
            }
            
            .list-item h3 {
                display:block;
                font:inherit;
                font-weight:bold;
                color:#222;
            }
        </style>
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="CPH_center" runat="server">
        <ext:GridPanel ID="GridPanel1" runat="server" Height="300" Title="Title">
            <TopBar>
                <ext:Toolbar ID="Toolbar1" runat="server">
                    <Items>
                        <ext:Button ID="Button1"
                            runat="server" 
                            Text="Skapa användare" 
                            Icon="Add">
                            <DirectEvents>
                                <Click OnEvent="Button1_Click">
                                    <EventMask ShowMask="true" />
                                </Click>
                            </DirectEvents>    
                        </ext:Button>
                        <ext:Button ID="Button_Refresh"
                            runat="server" 
                            Text="Uppdatera" 
                            Icon="Reload">
                            <DirectEvents>
                                <Click OnEvent="Button_Refresh_Click">
                                    <EventMask ShowMask="true" />
                                </Click>
                            </DirectEvents>    
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <Store>
                <ext:Store ID="Store1" runat="server" DataSourceID="ObjectDataSource1" OnRefreshData="RefreshUserStore">
                    <AutoLoadParams>
                        <ext:Parameter Name="start" Value="0" Mode="Raw" />
                        <ext:Parameter Name="limit" Value="10" Mode="Raw" />
                    </AutoLoadParams>
                    <Reader>
                        <ext:JsonReader IDProperty="UserId">
                            <Fields>
                                <ext:RecordField Name="UserId" />
                                <ext:RecordField Name="Firstname" />
                                <ext:RecordField Name="Lastname" />
                                <ext:RecordField Name="Type" />
                            </Fields>
                        </ext:JsonReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column ColumnID="UserId" Header="ID" Width="10" DataIndex="UserId" Hidden="true" />
                    <ext:Column DataIndex="Firstname" Header="Förnamn" Width="150" />
                    <ext:Column DataIndex="Lastname" Header="Efternamn" Width="150" />
                    <ext:Column DataIndex="Type" Header="Typ" Width="150" />
                </Columns>
            </ColumnModel>
            <View>
                <ext:GridView ID="GridView1" runat="server" EnableRowBody="true"></ext:GridView>
            </View>
            <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
            </SelectionModel>
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolbar1" 
                    runat="server" 
                    PageSize="10" 
                    DisplayInfo="true" 
                    DisplayMsg="Visar användare {0} - {1} of {2}" 
                    EmptyMsg="Inga användare att visa" 
                    />
            </BottomBar>
            <LoadMask ShowMask="true" />
        </ext:GridPanel>
        
        <ext:Window ID="Window_CreateUser" 
            runat="server" 
            Width="350"
            AutoHeight="true"
            Title="Skapa ny användare"
            Icon="Textfield"
            Closable="true"
            Padding="5"
            LabelWidth="125"
            Layout="Form"
            Hidden="true"
            Modal="true">
            <Items>
                <ext:TextField 
                    ID="txtFirstname" 
                    runat="server"                    
                    FieldLabel="Förnamn"
                    InputType="Text"
                    Width="175">                            
                </ext:TextField>
                <ext:TextField 
                    ID="txtLastname" 
                    runat="server"                    
                    FieldLabel="Efternamn"
                    InputType="Text"
                    Width="175">                            
                </ext:TextField>  
                <ext:TextField 
                    ID="txtEmail" 
                    runat="server"                    
                    FieldLabel="E-mail"
                    InputType="Text"
                    Width="175">                            
                </ext:TextField>  
                <ext:MultiCombo ID="MultiCombo_allowedLoginChannels" runat="server" SelectionMode="All" FieldLabel="Inloggning via" Width="175" 
                    DisplayField="typeName"
                    ValueField="typeObject"
                    EmptyText="Välj"
                    Selectable="true">
                    <Store>
                        <ext:Store ID="Store_LoginChannels" runat="server">
                            <Reader>
                                <ext:ArrayReader>
                                    <Fields>
                                        <ext:RecordField Name="typeStringId" />
                                        <ext:RecordField Name="typeName" />
                                        <ext:RecordField Name="typeObject" />
                                    </Fields>
                                </ext:ArrayReader>
                            </Reader>
                        </ext:Store>
                    </Store>
                </ext:MultiCombo>
                <ext:TextField 
                    ID="TextField1" 
                    runat="server"                    
                    FieldLabel="Lösenord"
                    InputType="Text"
                    Width="175">                            
                </ext:TextField>
                <ext:Button ID="Button_CreateUserSubmit" runat="server" Type="Submit" Text="Skapa användare">
                    <DirectEvents>
                        <Click OnEvent="Button_CreateUserSubmit_Click"></Click>
                    </DirectEvents>
                </ext:Button>
            </Items>            
        </ext:Window>    
    
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetObjects" 
            TypeName="Data_User" EnablePaging="true">
        </asp:ObjectDataSource>
    </asp:Content>
    <asp:Content ID="Content3" ContentPlaceHolderID="CPH_west" runat="server">
        
    </asp:Content>

    Users.aspx.cs (The relevant code to look at is in the Page_Load)


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Ext.Net;
    using System.Reflection;
    
    namespace WebApplicationExtNetTest.Secure.Views
    {
        public partial class Users : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
                List<object> asd = new List<object>();
                
                Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
                foreach (Assembly assembly in asms)
                {
                    Type[] typeArray = assembly.GetTypes();
                    foreach (Type type in typeArray)
                    {
                        if (type.IsSubclassOf(typeof(tWorks.Core.CoreCommons.Actors.ContactType)))
                        {
                            asd.Add(new object[] { type.ToString(), type.Name, type });
                        }
                    }
                }
    
                Store_LoginChannels.DataSource = asd;
                Store_LoginChannels.DataBind();
            }
    
            protected void Button1_Click(object sender, DirectEventArgs e)
            {
                    Window_CreateUser.Show();
            }
    
           
            protected void RefreshUserStore (object sender, StoreRefreshDataEventArgs e)
            {   
                this.Store1.DataSourceID = "ObjectDataSource1";
                this.Store1.DataBind();
            }
    
            protected void Button_Refresh_Click(object sender, DirectEventArgs e)
            {
                RefreshUserStore(sender, null);
            }
    
            protected void Button_CreateUserSubmit_Click(object sender, DirectEventArgs e)
            {
                  // Creates a User
            }
       }
    }
  4. #4
    Well, I still can't see the problem.

    Could you provide a sample what I could copy/paste and run? Like the one I posted.
  5. #5
    Hello and thanks for the reply =)

    Here is code you can copy-paste-run:


    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="WebApplicationExtNetTest.Secure.Views.Test" %>
    
    <%@ 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> asd = new List<object>();
    
                for (int i = 0; i < 10; i++)
                {
                    asd.Add(new object[] { i.ToString(), i.ToString() + "-test", new object() });
                }
    
                Store_LoginChannels.DataSource = asd;
                Store_LoginChannels.DataBind();
            }
        }
    
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            Window_CreateUser.Show();
        }
    </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></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager2" runat="server" />
        <div>
    
            <ext:Button ID="Button1" runat="server" Text="Submit">
                <DirectEvents>
                    <Click OnEvent="Button1_Click">
                        <EventMask ShowMask="true" />
                    </Click>
                </DirectEvents>    
            </ext:Button>
    
            <ext:Window ID="Window_CreateUser" 
            runat="server" 
            Width="350"
            AutoHeight="true"
            Title="Skapa ny användare"
            Icon="Textfield"
            Closable="true"
            Padding="5"
            LabelWidth="125"
            Layout="Form"
            Hidden="true"
            Modal="true">
            <Items>
                <ext:TextField 
                    ID="txtFirstname" 
                    runat="server"                    
                    FieldLabel="Förnamn"
                    InputType="Text"
                    Width="175">                            
                </ext:TextField>
                <ext:TextField 
                    ID="txtLastname" 
                    runat="server"                    
                    FieldLabel="Efternamn"
                    InputType="Text"
                    Width="175">                            
                </ext:TextField>  
                <ext:TextField 
                    ID="txtEmail" 
                    runat="server"                    
                    FieldLabel="E-mail"
                    InputType="Text"
                    Width="175">                            
                </ext:TextField>  
                <ext:MultiCombo ID="MultiCombo_allowedLoginChannels" runat="server" SelectionMode="All" FieldLabel="Inloggning via" Width="175" 
                    DisplayField="typeName"
                    ValueField="typeObject"
                    EmptyText="Välj"
                    Selectable="true">
                    <Store>
                        <ext:Store ID="Store_LoginChannels" runat="server">
                            <Reader>
                                <ext:ArrayReader>
                                    <Fields>
                                        <ext:RecordField Name="typeStringId" />
                                        <ext:RecordField Name="typeName" />
                                        <ext:RecordField Name="typeObject" />
                                    </Fields>
                                </ext:ArrayReader>
                            </Reader>
                        </ext:Store>
                    </Store>
                </ext:MultiCombo>
                <ext:TextField 
                    ID="TextField1" 
                    runat="server"                    
                    FieldLabel="Lösenord"
                    InputType="Text"
                    Width="175">                            
                </ext:TextField>
            </Items>            
        </ext:Window>    
        </div>
        </form>
    </body>
    </html>
  6. #6
    Thanks a lot.

    The one change I made: replace
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="WebApplicationExtNetTest.Secure.Views.Test" %>
    with
    <%@ Page Language="C#" %>
    Never mind:)

    I see the problem.

    The ValueField field must be unique. There is new object(), it is rendered as null on client side. MultiCombo doesn't allow null as value of its items.


    If you would replace
    asd.Add(new object[] { i.ToString(), i.ToString() + "-test", new object() });
    with, for example,
    asd.Add(new object[] { i.ToString(), i.ToString() + "-test", "value" + i });
    it will work fine.

    P.S. A simplified sample to reproduce in the initial post give you a good chance to get a solution quickly.
  7. #7
    Thanks for the info.

    However, I cant see that that is the problem. The code I posted was simplified, so Im not really adding just new Object() in the real app. This is how I populate the Store:

     List<object> asd = new List<object>();
                
                Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
                foreach (Assembly assembly in asms)
                {
                    Type[] typeArray = assembly.GetTypes();
                    foreach (Type type in typeArray)
                    {
                        if (type.IsSubclassOf(typeof(tWorks.Core.CoreCommons.Actors.ContactType)))
                        {
                            asd.Add(new object[] { type.ToString(), type.Name, type });
                        }
                    }
                }
    
                Store_LoginChannels.DataSource = asd;
                Store_LoginChannels.DataBind();
    Now, as you can see I add "type" to the list, and "type" is of type "Type". And the Type is different for each row in the List, so the same explanation isnt what is the problem here is my guess...

    I attached a picture to show that the data indeed is different.
    Click image for larger version. 

Name:	MultiComboProblem.png 
Views:	244 
Size:	62.1 KB 
ID:	2494
  8. #8
    Ok

    But if you would apply my this change
    asd.Add(new object[] { i.ToString(), i.ToString() + "-test", "value" + i });
    you will see that MultiCombo works fine when there are unique values.

    Again, I should request a sample to reproduce.

    Btw, why don't you want to use typeStringId as the MultiCombo's .ValueField? I'm pretty sure, it would work.
  9. #9
    Hi Daniil,

    Yes, you are absolutely correct that it works when having different values and of course there are other ways of working around the issue as you suggest. I will use the ToString() value of the Type instead, but it is of course important to understand why a certain behavior occurs. In this case and as I see it, there must be some form of error when adding Type-objects as a value to MultiCombo.

    Could be good to know in future updates =)

    Thanks for your help, very much appreciated =)

    Regards
  10. #10
    Well, how do you imagine Type object on client side?

    .DataBind() method means that DataSource data is "passed" to a client side store.

    The Type object is passed as
    "System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    You can see that in page source.

    As you can see there are commа symbols.

    MultiCombo has .Delimiter. It's a comma by default. MultiCombo doesn't allow a delimiter symbol in values.

    For example, you could set .Delimeter=";" and your initial code should work fine.
Page 1 of 2 12 LastLast

Similar Threads

  1. Can not select combobox items using store
    By blurken in forum 2.x Help
    Replies: 0
    Last Post: May 14, 2012, 1:23 AM
  2. Replies: 1
    Last Post: Feb 17, 2012, 7:22 AM
  3. Replies: 0
    Last Post: Sep 19, 2011, 11:11 AM
  4. [CLOSED] MultiCombo doesn't select items with comma in text
    By acrossdev in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Oct 19, 2010, 6:56 AM
  5. [CLOSED] Can't select items from multicombo
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 21, 2010, 10:10 AM

Tags for this Thread

Posting Permissions