It gets the human with ID 123 but then someHuman is not a store. Thus someHuman.sync() doesn't work, it says that sync() is not defined. Or if I use someHuman.save() it PUTs all the data to the server.

It gets the human with ID 123 but then someHuman is not a store. Thus someHuman.sync() doesn't work, it says that sync() is not defined. Or if I use someHuman.save() it PUTs all the data to the server.

Maybe I'm missing what you're trying to do, but I think you might be confused with the difference between a model and a store. A store is a collection of model records... or imagine it to be a glorified array of model instances.

If you're only wanting one instance of a person, MyApp.model.Person.load(1234) will give you what you're looking for and you can manipulate it however you want. Otherwise, what is the reason why you would want to get the people store and sync for just one person?

Keep in mind that the purpose of a store is to handle complex logic for every record that exists for that store. There might be a handful of records that need to be deleted, another handful that needs to be created, and many more that needs to be updated. store.sync() will will call all the necessary backend api's to handle the crud operations.

Maybe I'm missing what you're trying to do, but I think you might be confused with the difference between a model and a store. A store is a collection of model records... or imagine it to be a glorified array of model instances.

If you're only wanting one instance of a person, MyApp.model.Person.load(1234) will give you what you're looking for and you can manipulate it however you want. Otherwise, what is the reason why you would want to get the people store and sync for just one person?

I have tried with:

Code:

person = MyApp.model.Person.create({ id: 1234 });

but this has created an empty record. Actually I want to load it from my REST API.

Then I have tried to use:

Code:

person = MyApp.model.Person.load(1234);
console.log(person);

it has GET (the browser has loaded the data) the data from the REST API but console.log says that person is not defined.

One person has different properties such as e-mail and telephone. After I change his email I want to send this new data to server with PUT method aka person.save() or person.sync().

Ext.data.Model.create() will be exactly that... to create an instance. Whatever object literal you pass in will be the fields you want the model to be populated with. It'll be instantiated in memory only until you save() it.

If you want to change the create/update method from POST to PUT, you'll have to change the ajax proxy configured to model to use PUT by changing Ext.data.proxy.Ajax.actionMethods, which is by default {create: 'POST', read: 'GET', update: 'POST', destroy: 'POST'}.