[CLOSED] ComboBox ForceSelection with Store Data vs DataSource

  1. #1

    [CLOSED] ComboBox ForceSelection with Store Data vs DataSource

    UPDATE: I found this issue has already been addressed on the forum, please see my reply below.

    I'm having an issue with a ComboBox I'm creating from the code behind, where ForceSelection is set to true. If I load the ComboBox's store via DataSource then the value does not get set from the code behind on the initial load. However, if I use Data instead of DataSource, then it works. I want to use DataSource because it only serializes the fields that are in the store's model.

    The problem seems to come down to the fact that using DataSource loads the data via a MemoryProxy, while using Data sets the Store's data directly.

    Below is a simplified example. The combobox should select the single item it has upon loading, but it doesn't. If you change "DataSource" to "Data" then it will work like I'm expecting.

    
    <%@ Page Language="C#" %>
      
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            ComboBox TestCombo = new ComboBox
            {
                ID = "ComboBox1",
                ValueField = "Field1",
                DisplayField = "Field2",
                ForceSelection = true
            };
    
            TestCombo.Store.Add(new Store
            {
                Model = {
                        new Model {
                            Fields = {
                                new ModelField("Field1"), 
                                new ModelField("Field2")}
                        }
                    }
            });
    
            TestCombo.GetStore().DataSource = new object[] { new { Field1 = "asdf", Field2 = "qwerty" } };
            TestCombo.GetStore().DataBind();
            TestCombo.SetValue("asdf");
    
            ComboContainer.Items.Add(TestCombo);
        }
    </script>
     
    <!DOCTYPE html>
    <html>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Panel ID="ComboContainer" runat="server"></ext:Panel>
        </form>
    </body>
    </html>
    Last edited by Daniil; Oct 31, 2014 at 4:42 PM. Reason: [CLOSED]
  2. #2
    Just found this issue has already been logged here:

    http://forums.ext.net/showthread.php...ection-problem

    One of the workarounds mentioned here will work for me. Feel free to close this one.
    Last edited by tylert; Oct 31, 2014 at 4:14 PM.

Similar Threads

  1. [CLOSED] Difference between Store's Data and DataSource property
    By matrixwebtech in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 08, 2014, 9:37 AM
  2. Replies: 1
    Last Post: Jun 12, 2012, 10:34 AM
  3. Replies: 5
    Last Post: Feb 01, 2012, 11:54 AM
  4. [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
  5. Replies: 0
    Last Post: Feb 11, 2009, 3:05 AM

Tags for this Thread

Posting Permissions