Hi,
I'm new to ExtJS 5. I can't figure out how to get the stores in my ViewModel to work properly. I want the stores to get data from a json file. The ajax call is successful because I can see the http request to the users.json file. It must not be loading the data correctly into the stores. If I hard code the stores then it works. BTW, I am binding the data to a grid. I'm sure it's something simple. Thanks..
Code:
//MainModel.js file
Ext.define('sD.view.main.MainModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.main',
/***** defining stores like this works
stores: {
data: {
fields: ['id', 'name', 'email'],
data: [
{id: 101, name: 'Ed', email: 'ed@sencha.com'},
{id: 102, name: 'Tommy', email: 'tommy@sencha.com'}
]
}
}
*/
// defining like this doesn't work
stores: Ext.create('Ext.data.Store', {
autoLoad: true,
fields: ['id', 'name', 'email'],
proxy: {
type: 'ajax',
url: '/app/view/main/users.json',
reader: {
type: 'json',
rootProperty: 'data',
successProperty: 'success'
}
}
})
});
//users.json file
{
success: true,
data: [
{id: 101, name: 'Ed', email: 'ed@sencha.com'},
{id: 102, name: 'Tommy', email: 'tommy@sencha.com'}
]
}
Aucun commentaire:
Enregistrer un commentaire