4

I've exactly the same problem from this Question. However I'm using Sencha Touch 2 and I don't know how to actually use this custom store. I define my REST proxies inside the model classes. How would I access/use this custom proxy?

proxy: {
    type: 'rest',
    url: 'http://someUrl', 
    reader: {
        type: 'json',
    }
}
Community
  • 1
  • 1
karazy
  • 169
  • 4
  • 13

1 Answers1

10

It is fairly simple in Sencha Touch 2. This presumes you have an MVC architecture.

Firstly, you model - app/model/Image.js:

Ext.define('MyApp.model.Image', {
    extend: 'Ext.data.Model',

    // Require your custom proxy
    requires: ['MyApp.proxy.MyCustomProxy'],

    config: {
        fields: ['name'],

        proxy: {
            // set the type of your proxy
            type: 'mycustomproxy'
        }
    }
});

And then define your proxy - app/proxy/MyCustomProxy.js:

Ext.define('MyApp.proxy.MyCustomProxy', {
    extend: 'Ext.data.proxy.Proxy',

    // Set your proxy alias
    alias: 'proxy.mycustomproxy',

    ...
});
rdougan
  • 7,217
  • 2
  • 34
  • 63
  • Hey rdougan I am not able to display a list coming form a webservice.Here's link of that http://www.senchafiddle.com/#1AEdv It was running perfectly with local json file.Here's link of that http://www.senchafiddle.com/#b4K8w#rYgdP .Please provide me some solution here to display the list coming from webservice in xml format – himanshu May 10 '12 at 12:09
  • Extermely important is adding prefix 'proxy' to alias, so you get 'proxy.mycustomproxy' in proxy define. If not set loader will not recognize your class. – OSP Apr 12 '13 at 08:18