Reputation: 18961
I have a proxy defined on my Model.
I have a store defined pointing to the Model, no proxy, as I want it to use the one defined on the Model.
store.autoLoad
: true ain't working
I have to explicitly call from my Controller
var store = this.getMyStore();
store.load();
Is this expected behavior?
Code:
model/MyThing.js
Ext.define('MyApp.model.MyThing', {
extend: 'Ext.data.Model',
fields: ['id', 'reference'],
proxy:
{
type: 'ajax',
url: 'MyThings'
}
});
store/MyThings.js
Ext.define('MyApp.store.MyThings', {
extend: 'Ext.data.Store',
autoLoad: true,
autoSync: false,
model: 'MyApp.model.MyThing'
});
Upvotes: 1
Views: 4662
Reputation: 18961
Actually, this is a bit of a newbie thing. I've been a bit of an eager beaver.
I was looking at the store before it had completed loading (as its asynchronous).
Best practice is to subscribe to the load() function's callback and then do something...
store.load({
scope : this,
callback: function(records, operation, success) {
//the operation object contains all of the details of the load operation
console.log(records);
}
});
Upvotes: 0
Reputation: 12613
You don't show how you're creating the store. You should see an HTTP GET request in FireBug (assuming you're using FireFox and have it) as soon as you call:
Ext.create('MyApp.store.MyThings');
I added your code to my app and got the expected results, so it should be working.
UPDATE:
In response to your own posted answer, you can supply that config object as autoLoad
(rather than autoLoad: true
) to get the same functionality without having to explicitly call store.load()
Upvotes: 2