4

I have a jsonstore that is supposed to load a user's information. I have its HTTPRequest as a GET but when I finally do load up the store with parameters, it automatically changes to a POST request.

I've done something similar to this before, except it was a regular datastore, and the request stayed as a GET. Is the default behavior of a jsonstore when supplied with params to do a POST request?

    var userDisplayStore = new Ext.data.JsonStore({
        url : myurl/userinfo,
        method : 'GET',
        fields : ['firstName', 'lastName', 'email', 'userName'],
        id : 'user-display-store',
        root : 'data'
    });

    userGridPanel.on('rowclick', function(grid, dataIndex, event) {
        var dataRow = grid.getStore().getAt(dataIndex);
        userDisplayStore.load({
            params : {username : dataRow.data.username}
        });
    });

2 Answers 2

10

Try using a proxy with your store... and the method gets set as part of the proxy.

I think it would be something like this:

       var userDisplayStore = new Ext.data.JsonStore({
                fields : ['firstName', 'lastName', 'email', 'userName'],
                id : 'user-display-store',
                root : 'data',
                proxy : new Ext.data.HttpProxy({
                     method: 'GET',
                     url: 'myurl/userinfo'

                })
        });
1
  • Hi Spike, Thanks! That did it! This is how I would create a request with a regular data store, but the ext api mentioned that json store was pre-configured with a built-in HttpProxy so I never thought I'd need to use a proxy. Again, thanks! -Snowright
    – Snowright
    Nov 2, 2009 at 19:41
1

Another way,

var userDisplayStore = new Ext.data.JsonStore({
   url : myurl/userinfo,
   fields : ['firstName', 'lastName', 'email', 'userName'],
   id : 'user-display-store',
   root : 'data'
});
userDisplayStore.proxy.conn.method = 'GET';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.