Combobox SelectedItems by value icw store

  1. #1

    Combobox SelectedItems by value icw store

    Hi,
    When I fill a combobox with items by using a store (no inner items), and try to select an item by value, it does not work, no item is selected.
    When I try the index instead of value for the SelectedItems, it is working.

    Thanks for any help,
    Sander

    <%@ Page Language="C#" %>
    
    
    <%@ Import Namespace="System.Collections" %>
    <%@ Import Namespace="System.Linq" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        <style type="text/css">
            </style>
    
    
        <script runat="server">
            
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!X.IsAjaxRequest)
                {
                    List<object> list = new List<object>
                    {
                        new {Text = "Text3", Value = 3},
                        new {Text = "Text4", Value = 4},
                        new {Text = "Text5", Value = 5}
                    };
    
    
                    this.Store1.DataSource = list;
                    this.Store1.DataBind();
    
    
                    this.ComboBox1.SelectedItems.Add(new Ext.Net.ListItem { Value = "4" });
                }
            }
    
    
        </script>
    
    
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" AjaxViewStateMode="Enabled">
        </ext:ResourceManager>
        <form id="form2" runat="server">
            <ext:FormPanel runat="server" ID="MainPanel" Title="test..." Height="200">
                <Items>
                    <ext:ComboBox
                        ID="ComboBox1"
                        runat="server"
                        DisplayField="Text"
                        ValueField="Value"
                        QueryMode="Local">
                        <Store>
                            <ext:Store ID="Store1" runat="server">
                                <Model>
                                    <ext:Model ID="Model1" runat="server" IDProperty="Value">
                                        <Fields>
                                            <ext:ModelField Name="Text" />
                                            <ext:ModelField Name="Value" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                            </ext:Store>
                        </Store>
                    </ext:ComboBox>
                </Items>
            </ext:FormPanel>
        </form>
    </body>
    </html>
  2. #2
    When I chage the type of the value from int to string, it is working.

    List<object> list = new List<object>
                    {
                        new {Text = "Text3", Value = "3"},
                        new {Text = "Text4", Value = "4"},
                        new {Text = "Text5", Value = "5"}
                    };
    maybe a suggestion to change this in the example also...

    https://examples2.ext.net/#/Form/Com...Items_Actions/

Similar Threads

  1. Replies: 2
    Last Post: Sep 15, 2014, 2:58 PM
  2. [CLOSED] ComboBox / Store / DataSource : Store.DataSource is NULL
    By wagger in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Apr 24, 2011, 10:09 AM
  3. Split multicombo selectedItems (server side)
    By asazine in forum 1.x Help
    Replies: 2
    Last Post: Mar 10, 2011, 2:25 PM
  4. [CLOSED] multiselect set selecteditems
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 02, 2009, 7:09 PM
  5. Replies: 1
    Last Post: Jan 07, 2009, 1:38 PM

Tags for this Thread

Posting Permissions