[CLOSED] [1.0] Custom search help

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] [1.0] Custom search help

    Hello,

    I'm trying to use custom search comboBox. I've seen that it use a webservice as datasource (store), is possible make this example with a directmethod?

    Can I use a standard webservice or wcf, that not inherit of IHttpHandler or its is mandatory?

    Could give a few examples using proxies?

    Thanks
    Last edited by Daniil; Oct 28, 2010 at 5:45 PM. Reason: [CLOSED]
  2. #2
    Hi edigital,

    The same technique as in this example
    https://examples1.ext.net/#/Form/Com...Custom_Search/
    should work with all types of proxies.

    Here is a simplified example with PageProxy.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Import Namespace="System.Linq" %>
    
    <script runat="server">
        private object[] MyData = 
            new object[] 
            {
                new object[] { "a" },
                new object[] { "b" },
                new object[] { "c" },
                new object[] { "a1" },
                new object[] { "b1" },
                new object[] { "b2" }
            };
    
        protected void Store_Refresh(object sender, StoreRefreshDataEventArgs e)
        {
            Store store = sender as Store;
            string filter = e.Parameters["query"];
            var filteredList = from x in MyData
                               where (x as object[])[0].ToString().StartsWith(filter)
                               select x;
            store.DataSource = filteredList;
            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 
            runat="server" 
            DisplayField="test" 
            ValueField="test" 
            TypeAhead="false"
            LoadingText="Searching..." 
            MinChars="1" 
            HideTrigger="true">
            <Store>
                <ext:Store 
                    runat="server" 
                    AutoLoad="false" 
                    OnRefreshData="Store_Refresh">
                    <Proxy>
                        <ext:PageProxy />
                    </Proxy>
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
        </ext:ComboBox>
        </form>
    </body>
    </html>
    Last edited by Daniil; Oct 28, 2010 at 11:06 AM.
  3. #3
    Hi Daniil,

    I dont understand well the role of Proxy, and when I need to use a proxy instead a datasource. Could you explain me shortly?.

    And the use of a proxy is mandatory or I can use a datasource.?

    Thanks
  4. #4
    Hi,

    I'll try to explain.

    The Store needs some data.
    You have to give a Store this data.
    You could give it trough DataSource. If it's possible.
    But data can be placed anywhere. For example, on another page.

    Store with Proxy makes a request for a data object from a respective source - a current page (PageProxy), another page from the same domain (HttpProxy), another page from another domain (ScriptTagProxy), WebService (HttpProxy).
  5. #5
    Hi,

    Thanks for the explain, then my question is if I can use a datasource (point to a function to query data) instead a proxy to make the comboBox custom search?

    Thanks.
  6. #6
    I used PageProxy because it provides me with handy mechanism to trigger searching.
    Sure, it can be implemented without Proxy.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Import Namespace="System.Linq" %>
     
    <script runat="server">
        private object[] MyData =
            new object[]
            {
                new object[] { "a" },
                new object[] { "b" },
                new object[] { "c" },
                new object[] { "a1" },
                new object[] { "b1" },
                new object[] { "c1" }
            };
     
        [DirectMethod]
        public void GetData(string filter)
        {
            Store store = this.ComboBox1.GetStore();
            if (string.IsNullOrEmpty(filter))
            {
                return;
            }
            else if (filter.Equals("*"))
            {
                store.DataSource = MyData;
            }
            else
            {
                store.DataSource = from x in MyData
                               where (x as object[])[0].ToString().StartsWith(filter)
                               select x;
            }
            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" 
            DisplayField="test" 
            ValueField="test"
            TypeAhead="false" 
            HideTrigger="true" 
            EnableKeyEvents="true">
            <Store>
                <ext:Store runat="server" AutoLoad="false">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <Listeners>
                <KeyUp Handler="Ext.net.DirectMethods.GetData(this.getRawValue());" />
            </Listeners>
        </ext:ComboBox>
        </form>
    </body>
    </html>
    Last edited by Daniil; Nov 05, 2010 at 12:01 PM. Reason: Code formatting
  7. #7
    Hi Daniil,

    I've tried to add a listener to my store with:

    St.AddListener( "KeyUp", "Ext.net.DirectMethods.LoadAutoCompleteData(this.getRawValue());" );
    But it generate a javascript error in the page.

    could you tell if its correct, I dont know what is the way to add listeners to store at runtime?

    Thanks
  8. #8
    I guess you should add listener to ComboBox, not Store.

    Please use
    combo.Listeners.KeyUp.Handler = "Ext.net.DirectMethods.LoadAutoCompleteData(this.getRawValue());";
  9. #9
    Hi Daniil,

    Thanks so much Daniil

    Regards
  10. #10
    Hi Daniil,

    In all examples I've seen that displayField and valueField properties point to same recordField, it must be as is or it could be pointed to a differents recordfields.

    By example: displayField point to name and valuedField point to id.

    Thanks
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Custom Search Combobox
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 04, 2010, 7:29 PM
  2. [CLOSED] [1.0] custom search
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 23, 2010, 3:48 PM
  3. [CLOSED] custom search v1.0 IE6
    By sharif in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 18, 2010, 7:05 PM
  4. [CLOSED] [1.0] ComboBox Custom Search
    By bethc in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 20, 2009, 8:25 AM
  5. Custom Search
    By sharif in forum 1.x Help
    Replies: 0
    Last Post: Jul 14, 2009, 4:04 PM

Tags for this Thread

Posting Permissions