View Full Version : Store with ajax proxy

9 Jun 2013, 1:25 AM
Can someone help me with the configuration to a store that should fetch records (and update create delete them)?
I have WCF ajax enabled service defined in my site, the svc file named Customers.svc and i'm using asp:ScriptManager .
I tried this configuration and it doesn't seemed to work:

Ext.define('Ronen.stores.Customer', { extend: 'Ronen.stores.Store', requires: ['Ronen.models.Customer', 'Ronen.stores.Store'], model: 'Ronen.models.Customer', alias: 'RonenStoreCustomer', proxy: { type: 'ajax', url: '/Customers.svc', api: { read: '/Customers.svc/Customer_GetStore' }, reader: { type: 'json', root: 'Customers' } }, autoLoad: true,

10 Jun 2013, 12:43 PM
At first glance your code looks fine (though you should alias with "store.RonenStoreCustomer").

What does the data come back from your server looking like?

11 Jun 2013, 12:16 AM
I have another problem I'm not sure whether it relates or not.

I'm gettin' this console warning [W] Ext.data.Store created with no model.
and this error TypeError: me.model is undefined in the line:

me.setProxy(me.proxy || me.model.getProxy());

on the function Ext.data.AbstractStore#constructor

11 Jun 2013, 3:08 PM
That does sound bad.
Are you defining "Ronen.models.Customer" in app/models/Customer.js?

*Also, conventionally you'll define these as Namespace.model.Class and they'll be in app/model/Class.js (versus models).

11 Jun 2013, 11:34 PM
models.Model and models.Customer which extends models.Model defined in js/models (i'll change it to model instead of models).

stores.Store and stores.Customer which extends stores.Store defined in js/stores (i'll change stores to store as well).

in my app.js i have a setPath('Ronen', 'js') call.

I can't figure what the problem is... am i missing something? maybe some kind of more then 1 extend level problem?

12 Jun 2013, 2:18 PM
You can use whatever folder names you'd like - you'll just need to make sure that you're naming / requiring the classes in accordance with your folder structure is all.

Do you have an Ext.application and in that application it's referencing a controller? And in that controller it's got a models: config and a stores: config with your application's models and stores listed in their respective arrays?

In your developer tools on the network tab are you seeing Ronen.models.Customer (the Customer.js) file being downloaded?

13 Jun 2013, 1:21 AM
this is how my app.js looke like:

Ext.Loader.setPath('Ronen', 'js'); Ext.require('Ronen.widgets.windows.Customer'); Ext.onReady(function () { Ext.create('Ronen.widgets.windows.Customer').show(); });

Ronen.widgets.windows.Customer contains 2 items - grid and panel. the Ronen.stores.Customer (which extends Ronen.stores.Store) is attached to the grid. the Ronen.models.Customer (which extends Ronen.models.model) attached to the store.

I can see all of them in the DOM in firebug

14 Jun 2013, 12:44 PM
Is 'Ronen' your app name or it's just a separate set of classes you'll be using with your app?

And are you defining your Ronen.stores.Store and Ronen.stores.Customer and Ronen.widgets.windows.Customer all in their own JS files under their respective folder paths based on their class name?

15 Jun 2013, 11:25 PM
'Ronen' is not my iis app name, it's basically set with SetPath() to point to 'js' folder which contains all the js file except of app.js.
every class defined in in it's own file and under it's respective folder -

17 Jun 2013, 12:11 PM
Do you have Ronen.stores.Customer in a controller (or app's) stores config anywhere?
Or do you have it in a requires config in the class using the store? Sounds like it's not getting loaded before it's needing to be instantiated by the grid.