'How to load a rest store with ID in Sencha Touch 2.4.2?
Here within a controller I create a rest store:
this.somePerson = Ext.create('Ilhan.store.Human', {
model: 'Ilhan.model.Human',
autoLoad: false
});
this.somePerson(123);
But it doesn't load the person with id 123 even though I have set idProperty in the model. It loadds all the humans.
This one loads can retrieve the human with ID 123.
Ext.ModelManager.getModel('Ilhan.model.Human').load(record.data.ID, {
success: function(recordd) {
someHuman = recordd;
}
});
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.
Solution 1:[1]
You must look at findBy.
example (not tested):
var indexOfHuman123 = this.somePerson.findBy( function(recordTest){
if( recordTest.get('id') == 123 )
return true;
return false;
});
var modelOfHuman123;
if( indexOfHuman123 != -1 )
modelOfHuman123 = this.somePerson.getAt(indexOfHuman123);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | badboyunited |
