1

I am creating a search form in Sencha Touch 2. The form is created, the fields are all there. But how do I call the /users/{param} url? I've got a store, and it can load "all" users, but I'd like to load specific data .. Thx.

Edit:

Ext.define('TCM.store.Users', {
    extend: 'Ext.data.Store',

    config: {
        model: 'TCM.model.User',
        sorters: 'name',
        proxy: {
            type: 'rest',
            url: 'http://local.test.eu/app_dev.php/api/users'
        }
    }
});
mattyh88
  • 1,585
  • 5
  • 26
  • 48

2 Answers2

4

You just need to get the proxy of your store and set the extraParams:

Ext.getStore('Users').getProxy().setExtraParams({
  param: myParam
});

If all the data of you store is already loaded, you also could filter it instead of reloading it.

Hope this helped

Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121
  • Hey, thank you for your answer and sorry for the late reply. My server broke down so couldn't do much work. Up and running again now. So I'm using my store to get the users that match the search data. But the search always returns all users because my store is configured with the url in my first post. How can I fix this? – mattyh88 Dec 19 '12 at 12:40
2

You can to pass params to the store.load method like this

Ext.getStore('Users').load({
   params : { param : 'param1'}
});

If you need build specific url according params, you should to override buildUrl method in proxy

 buildUrl : function (request) {
            var url = this.getUrl(request),//  /users/
                params = request.getParams() || {};

            url = url + params.param; // /users/param1
            request.setUrl(url);
            return this.callParent([request]);
    }
Nikolai Borisik
  • 1,501
  • 13
  • 22