[SOLVED] ComboBox Stores
New Community Forums available at http://forums.ext.net
 

Coolite Forums

Welcome Guest ( Login | Register )
 
[SOLVED] ComboBox Stores
Subscribe
Last Login: 6/11/2010 2:47:39 PM
Posts: 364,
Posted 8/19/2009 3:45:38 PM

Group: Coolite Premium Member & Early Adopter
 Alright, another question.

I have a ComboBox that needs to have an AutoComplete feature.  I have seen the example of with the Custom Search, however, it uses a WebService.  I am unable to use WebServices or anything that deviates from the architecture that is already in place here.

Even if I could use the example code as a basis, I don't know if it would work for us since I'm dealing with a database of over 144 million records for the "search" of this field.  What we're trying to accomplish is very similar to the Google search field on the Google homepage.

So, having said this.  Below is the code I have.

.aspx:

    <ext:Store ID="strNames" runat="server" OnRefreshData="strNames_RefreshData">
        <Reader>
            <ext:JsonReader>
                <Fields>
                    <ext:RecordField Name="NameId" />
                    <ext:RecordField Name="FullName" />
                </Fields>
            </ext:JsonReader>
        <Reader>
    </ext:StoreID>

    <ext:ComboBox ID="cbNames" runat="server" StoreID="strNames" DisplayField="FullName" ValueField="NameId" HideTrigger="true" MinChars="1" />


.aspx.cs:

protected void strNames_RefreshData(object sender, StoreRefreshDataEventArgs e)
{
    // This function should take the text already typed and search for any records beginning
    // with the values typed. Name Search is looking in the database is:
    // SELECT TOP 10 * FROM Names WHERE FullName LIKE search + '%'

    string search = ((ListItem)cbNames.Value).Value;
    DataTable names = null;

    if (!string.IsNullOrEmpty(search))
    {
        // Make database connection here, return results as DataTable
        names = namesDb.NameSearch(search);
    }

    strNames.DataSource = names;
    strNames.DataBind();
}


I was expecting since I already bound the ComboBox to the Store that whenever a user types a character it would fire the RefreshData on the Store to get "new" data.  But that doesn't seem to work.

Any help?
Last Login: 7/5/2010 10:10:13 AM
Posts: 7,853,
Posted 8/20/2009 2:11:18 AM

Group: Core Development Team
Hi,

Just add DataSourceProxy to the store

--
Vladimir Shcheglov
Coolite Inc.
Development Team
Forum Guidelines | Coolite Examples | Coolite API Docs | ExtJS API Docs | Twitter
Last Login: 6/11/2010 2:47:39 PM
Posts: 364,
Posted 8/20/2009 10:43:08 AM

Group: Coolite Premium Member & Early Adopter

This worked.

All I did was add to the store:


<Proxy>
    <ext:DataSourceProxy />
</Proxy>


Thanks.

« Prev Topic | Next Topic »
Reading This Topic
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.
All times are GMT -5:00, Time now is 8:33pm