[CLOSED] How to Populate Combobox on Focus?

  1. #1

    [CLOSED] How to Populate Combobox on Focus?

    Hi,

    How can i populate the data in a combobox when the user focuses on the combbox. I tried like this but not able see the data.

    <ext:ComboBox ID="ComboBoxSito" runat="server" Width="350px" MinListWidth="450px"
          ValueField="Value" DisplayField="Text" TypeAhead="true" HideTrigger="true"
          MinChars="1" FieldLabel="Columns" LabelWidth="30">
          <Store>
             <ext:Store runat="server" OnRefreshData="RefreshData">
                <Reader>
                   <ext:JsonReader>
                      <Fields>
                         <ext:RecordField Name="Text"  />
                         <ext:RecordField Name="Value" />
                      </Fields>
                   </ext:JsonReader>
                </Reader>
             </ext:Store>
          </Store>
          <Listeners>
          </Listeners>
       </ext:ComboBox>
    Note:
    1. The data must be returned from an ASPX server side method.
    2. I do not want to use the HTTP Proxy as explained in the Custom Search example.

    Regards,
    Manoj.
    Last edited by Daniil; Aug 01, 2011 at 7:03 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I can suggest you to use DirectMethod.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        [DirectMethod]    
        public void DataBind()
        {
            Store store = this.ComboBox1.GetStore();
            store.DataSource = new object[] 
                { 
                    new object[] { "1", "item1: " + DateTime.Now.ToLongTimeString() },
                    new object[] { "2", "item2: " + DateTime.Now.ToLongTimeString() },
                    new object[] { "3", "item3: " + DateTime.Now.ToLongTimeString() }
                };
            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:ComboBox ID="ComboBox1" runat="server">
                <Store>
                    <ext:Store runat="server" AutoLoad="false">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="value" />
                                    <ext:RecordField Name="text" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <Listeners>
                    <Focus Handler="Ext.net.DirectMethods.DataBind();" />
                </Listeners>
            </ext:ComboBox>
        </form>
    </body>
    </html>
  3. #3
    Hi Daniil,

    Thank you. I was able achive what i want.

Similar Threads

  1. [CLOSED] ComboBox Focus Expanded
    By jeybonnet in forum 1.x Legacy Premium Help
    Replies: 17
    Last Post: Jan 16, 2013, 3:04 PM
  2. Replies: 4
    Last Post: Feb 21, 2012, 4:23 AM
  3. [CLOSED] combobox populate
    By nhg_itd in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 17, 2011, 9:08 AM
  4. Replies: 12
    Last Post: Jun 30, 2010, 9:31 PM
  5. Replies: 1
    Last Post: May 08, 2009, 5:34 PM

Posting Permissions