PDA

View Full Version : single item fetch with REST proxy



alexmufatti
16 Jan 2012, 6:21 AM
Hello,
is it possible to fetch a single item using a REST proxy?

For example:


Ext.define('AM.store.UserDetails', {
extend: 'Ext.data.Store',
model: 'AM.model.UserDetails',

proxy: {
type: 'rest',
url: '/Server/index.php/users',
reader: {
type: 'json',
root: 'Data',
successProperty: 'success'
}
}
});


and then use the store like this:



store.load({params : {id:1}});


to call address: /Server/index.php/users/1 ?

I only succeeded in loading all the items in one call doing a store.load() but this is not a good choice if you have thousands of records.

thank you

hendricd
16 Jan 2012, 7:21 AM
@alex -- Review the documentation notes on the use of Model instances (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Model).

Hint: Just move your proxy definition to your Model ;)

alexmufatti
16 Jan 2012, 7:26 AM
@alex -- Review the documentation notes on the use of Model instances (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Model).

Hint: Just move your proxy definition to your Model ;)

Thank you, I got it!