PDA

View Full Version : Setting up an Ajax store



mrtedweb
12 Apr 2013, 9:03 AM
Hello everyone,

I am in the process of setting up a store using an Ajax proxy to communicate with a C# WCF service. Using Firebug I can see that the call is receiving data in the response, but it's not being loaded into the store. Below is my code:

Model:

Ext.define('Desktop.model.session.UserModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'FirstName', type: 'string'},
{name: 'GUID', type: 'string'}
]
});

Store:

Ext.define('Desktop.store.session.UserStore', {
extend: Ext.data.Store,

model: 'Desktop.model.session.UserModel',

proxy: {
type: 'ajax',
url: '/Session.svc/SignIn',
method: 'GET',
headers: { 'Content-Type': 'application/json;charset=utf-8' },
reader: {
type: 'json',
root: 'root'
}
},

reader: {
type: 'json'
}
});

Controller:

this.store = Ext.create('Desktop.store.session.UserStore', {});
var username = 'jdoe';
var password = 'password1!'
this.store.getProxy().setExtraParam("username", username);
this.store.getProxy().setExtraParam("password", password);
this.store.load();

Response from WCF service:

{
"FirstName": "John",
"LastName": "Doe",
"GUID": "12345"
}

Everything seems to run perfectly except once again, that data is not being loaded into the store. The records are empty. Any help anyone can provide would be greatly appreciated!

skirtle
12 Apr 2013, 4:02 PM
The reader config that's directly on the store won't do anything, get rid of that.

The reader config on the proxy has a root set when it shouldn't. Try removing the root.