I'm developing an Extjs 6 application using MVVM architecture. I have a model in MyApp/model folder as follow:
Ext.define('MyApp.model.User', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'},
{name: 'age', type: 'int'}
]
});
And my store in MyApp/store folder is as follow:
Ext.define('MyApp.store.User', {
extend: 'Ext.data.Store',
model: 'MyApp.model.User',
data : [
{firstName: 'Seth', age: 34},
{firstName: 'Scott', age: 72},
{firstName: 'Gary', age: 19},
{firstName: 'Capybara', age: 208}
]
});
And the in Application.js in /MyApp folder add the store as follow:
stores: [
'User'
]
now I get store in my application as follow:
app = MyApp.getApplication();
users = app.getStore('User');
How can I get store's data? users.getData()? When I user users.getData() it returns [undefined x 4]. Where is the problem? Is it work correctly?
you are using it correctly. You have to use
users.getData().itemsas follow:app = MyApp.getApplication(); users = app.getStore('User'); users.getData().items;