[CLOSED] Combobox with a store proxy load on expand

  1. #1

    [CLOSED] Combobox with a store proxy load on expand

    Hi,

    Like in Title I have made that but now I have problem because it's display only Id on begin (before load store by proxy).

    Is there any way to load only 1 item if(there is some id already exist in my object)?
    My object are loaded on load of edit form. So can I insert there pair value like (Name=valuefrommyobject, Id=valueofmyobject) without reloading store?

    I need that functionality to make huge performance:)

    I found that I can make this like in sample below in theory:
    Combobox combo = new Combobox();
    //configure store and jsonreader
    combo.GetStore().Set("Text to display", 1); //but it's make js error in browser says  ReferenceError: invalid assignment left-hand side
    mb it should be done differently?

    Thanks,
    ViDom
    Last edited by Daniil; Nov 22, 2012 at 2:42 PM. Reason: [CLOSED]
  2. #2
    Hi @Vidom,

    You can populate ComboBox's Items collection with this single item.

    Then you might need to remove this item before loading other items.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @Vidom,

    You can populate ComboBox's Items collection with this single item.

    Then you might need to remove this item before loading other items.
    loading store loads async items collection of combobox?
  4. #4
    Or if you can tell me which DirectEvent should I use to load Data on expand since

    DirectEvents.Expand.Event += new ComponentDirectEvent.DirectEventHandler(Event);
    doesn't work on expand:( in debug it doesn't reach breakpoint in Event method

    Any ideas?
  5. #5
    My initial suggestion won't work.

    You can try the following solution. But it is a trick. It is better to preload a required item.

    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)
            {
                this.ComboBox1.SelectedItem.Value = "1";
                this.ComboBox1.Text = "item1";
            }
        }
    
        protected void RefreshData(object sender, StoreRefreshDataEventArgs e)
        {
            Store store = sender as Store;
            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>
        <ext:ResourceManager runat="server" />
    
        <ext:ComboBox ID="ComboBox1" runat="server">
            <Store>
                <ext:Store 
                    runat="server" 
                    OnRefreshData="RefreshData" 
                    AutoLoad="false">
                    <Proxy>
                        <ext:PageProxy />
                    </Proxy>
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="value" />
                                <ext:RecordField Name="text" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
        </ext:ComboBox>
    </body>
    </html>
  6. #6
    Quote Originally Posted by Daniil View Post
    My initial suggestion won't work.

    You can try the following solution. But it is a trick. It is better to preload a required item.

    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)
            {
                this.ComboBox1.SelectedItem.Value = "1";
                this.ComboBox1.Text = "item1";
            }
        }
    
        protected void RefreshData(object sender, StoreRefreshDataEventArgs e)
        {
            Store store = sender as Store;
            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>
        <ext:ResourceManager runat="server" />
    
        <ext:ComboBox ID="ComboBox1" runat="server">
            <Store>
                <ext:Store 
                    runat="server" 
                    OnRefreshData="RefreshData" 
                    AutoLoad="false">
                    <Proxy>
                        <ext:PageProxy />
                    </Proxy>
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="value" />
                                <ext:RecordField Name="text" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
        </ext:ComboBox>
    </body>
    </html>
    I've make my proxy work properly.

    Now it's populate combobox after handler retrive data from database but DisplayText of Item is always null and now I got combobox with empty values.

    attached image will show what I mean:
    Click image for larger version. 

Name:	capture3.jpg 
Views:	152 
Size:	9.9 KB 
ID:	5115

    Any suggestion what can cause this? RecordField.Name is equal Property name in retrived data for sure.
    Need to configure anything else on json reader?

    here's my configuration:
    Ext.Net.JsonReader reader = new JsonReader();
                    reader.IDProperty = "Id";
                    reader.MessageProperty = "Name";
                    reader.TotalProperty = "TotalRecords";
                    reader.Fields.AddRange(new List<RecordField> { new RecordField("Id", RecordFieldType.Int), new RecordField("Name", RecordFieldType.String) });
  7. #7
    Hard to say.

    Please provide a sample to reproduce.

Similar Threads

  1. [CLOSED] Rest proxy load and autoload
    By Akpenob in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Nov 06, 2012, 8:08 AM
  2. Replies: 9
    Last Post: Oct 16, 2012, 12:05 AM
  3. [CLOSED] Load data to store of combobox by proxy
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Oct 08, 2012, 8:29 AM
  4. Replies: 13
    Last Post: Sep 07, 2012, 6:23 PM
  5. combobox expand on store refresh
    By ascsolutions in forum 1.x Help
    Replies: 0
    Last Post: Jun 19, 2012, 1:38 PM

Tags for this Thread

Posting Permissions