views:

2083

answers:

5

This is my first bash at using extJS, and after a few hours of struggling, some things are working OK, except I have combo lists that I can't filter down to less than 2000 items in edge cases, so I'm trying to page the lists through remotely, but I must be doing something wrong.

My data store and combo look as follows:

var remoteStore = new Ext.data.JsonStore({
        //autoLoad    : true,
        url         : 'addition-lists.aspx',
        fields      : [{name: 'extension_id'}, {name: 'extension'}],
        root        : 'extensionList',
        id          : 'remoteStore'               
    });
.
.
                        xtype         : 'combo',
                        fieldLabel    : 'Remote',
                        name          : 'remote',
                        displayField  : 'extension',
                        valueField    : 'extension_id',
                        mode          : 'remote', 
                        //pageSize      : 20,
                        triggerAction : 'query',  
                        typeAhead     : true,                    
                        store         : remoteStore,
                        anchor        : '95%'

The combo works loading locally, but as soon as I switch to remote it remains blank.

My ASP.NET page returning the JSON is like this:

protected void Page_Load(object sender, EventArgs e)
{
    Response.Clear();
    Response.Write(GetRemote());
}
A: 

You can refer to this question http://stackoverflow.com/questions/681995/extjs-combobox-problem-in-ie

Rutesh Makhijani
A: 
Thevs
+1  A: 

On remote stores the combo defaults its minChars property to 4, so the query only gets sent after typing 4 chars. Setting minChars almost gives the desired behaviour.

I say almost because even if the item sought by autocomplete is in the current page, a new server query still gets sent, defaulting the selection to the first item in the new page.

ProfK
A: 

Several things. First, when doing this:

remoteStore.loadData(<%= GetRemote() %>);

you are not actually making a remote call from your javascript. You are echoing the result of calling the GetRemote server function directly into the page at render time. Probably not what you intend? If GetRemote is writing out your combo data (and it's working correctly), then you should be able to use a combo setup for local data. If the intention really is to make a remote call, then you need to remove the server tag and load data via the proxy url as shown in several examples that come with Ext.

Another thing is that your Page_Load code doesn't actually show anything about how you are loading, formatting or returning your data. I would suggest viewing source and verifying that your tag is actually being replaced with the data you expect. If/when you switch it to a true remote call to load data then you can use Firebug to inspect your XHR calls and verify the data coming down that way.

bmoeskau
@bmoeskau: Apologies, that 'loadData' call remained after my debugging - it was just there to verify that things worked locally. Please see my answer above for the real problem.
ProfK
+1  A: 

The way you configured your store above, the result from your ASP script should read something like this:

{"extensionList": [
  {"extension_id": 1, "extension": "js"},
  {"extension_id": 2, "extension": "aspx"}
]}

If it doesn't look like that, your remote store will not find anything.

Jochen