[CLOSED] [1.0] Custom Search dynamic item count

  1. #1

    [CLOSED] [1.0] Custom Search dynamic item count

    I am using an ext:combobox control with custom search and need to find the count of items in the combobox on the fly.

    The combobox is populated by an HttpProxy that calls an ashx. The content of the combobox currently works correctly, where as you type it filters the combobox with the results of the ashx handler similar to the example. The part that is needed is to retrieve the count of the results that come back on the fly. For instance as the combobox data changes after each letter is typed, I need to capture the count so I can test it and change other elements on the page accordingly.
    Last edited by Daniil; Nov 09, 2010 at 1:45 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please use the Store's DataChanged event.

    Example
    <ext:Store runat="server" AutoLoad="false">
       ...
        <Listeners>
            <DataChanged Handler="alert(this.getCount())"/>
        </Listeners>
    </ext:Store>
    Here is a full example.

    Full 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>
                    <Listeners>
                        <DataChanged Handler="alert(this.getCount())"/>
                    </Listeners>
                </ext:Store>
            </Store>
            <Listeners>
                <KeyUp Handler="Ext.net.DirectMethods.GetData(this.getRawValue());" />
            </Listeners>
        </ext:ComboBox>
        </form>
    </body>
    </html>
  3. #3

    [CLOSED] thanks

    Thanks Daniil. Nicely demonstrated.

Similar Threads

  1. Replies: 3
    Last Post: Jan 21, 2011, 1:19 PM
  2. Replies: 1
    Last Post: Jun 04, 2010, 5:21 PM
  3. [CLOSED] Item Count for Store - Server Side
    By JD in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 02, 2010, 9:07 AM
  4. Replies: 1
    Last Post: Oct 27, 2009, 10:39 AM
  5. [CLOSED] GridPanel + Dynamic Columns + Count
    By Zarzand in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jul 10, 2009, 4:46 PM

Posting Permissions