PDA

View Full Version : Issue loading json store to form



Anthony.Hall
11 Jan 2012, 7:55 AM
I have the following code. I'm trying to create the store via json. I can see that firebug calls the json but this data is not loading the form. This is working with a local instance of the of model. So i confident that the panel that contains "formJobSummary" is working. The issue is somewhere on the store.


Ext.define('user', { extend: 'Ext.data.Model
fields: ['quotedPrice']
});
var store = Ext.create('Ext.data.Store', {
model: 'user',
proxy: {
type: 'ajax',
url: '/data/users.js',
reader: {
type: 'json',
root: 'user'
}
},
autoLoad: true
});




Ext.define('MyApp.view.MyPanel', {
extend: 'MyApp.view.ui.MyPanel',
initComponent: function () {
var me = this;
me.callParent(arguments);
var form = Ext.getCmp('formJobSummary');
form.loadRecord(store);
}
});





Json '/data/users.js'


{ "success":"true",
"user": [{
"quotedPrice":"12345"
}]
}

tobiu
11 Jan 2012, 8:04 AM
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.Panel-method-loadRecord

expects a record as a parameter, you are passing the store instance instead.

Anthony.Hall
11 Jan 2012, 8:34 AM
thanks, so i think that means i need to do something like.

var form = Ext.getCmp('formJobSummary');
form.loadRecord(user);

Sorry to be dumb, do you mind expanding on this a little.