View Full Version : Dinamic url in MVC app Store

29 Jan 2012, 10:52 PM
Is there a way to define a store in a MVC app with a dinamic url like this?

Ext.define('GpMobile.store.Customers', {
extend: 'Ext.data.Store',
model: 'GpMobile.model.Customers',
timeout : 3000,
proxy : {
url: this.getApplication().getController('Main').config.server.domain+"/service.aspx?methodName=sqlExecute&args=["+'"'+"sql"+'":"'+"SELECT [anagra].[an_conto], [anagra].[an_descr1] FROM anagra WHERE [anagra].[an_tipo]='C'"+'"]',
callbackKey: 'callback',
type : 'jsonp',
clearOnPageLoad: false,
type : 'json',
rootProperty : 'results',
totalCount : 'total'

At app sturtup, when my Customers.js is loading I recive this error, because the store scope is DOMWindow:
Uncaught TypeError: Object [object DOMWindow] has no method 'getApplication'

Thanks in advance

30 Jan 2012, 9:07 AM
If you use this outside of a method like constructor then the scope will be of the document which is not what you want. What I do is create a utility class to handle my URLs.

Say my app's name is 'MyApp', I then create a folder app/util/ and have a class in it that I can then use the off the namespace...

Ext.define('MyApp.util.Config', {
singleton : true,

config : {
customersUrl : 'path/to/customers

Then in my store I can do MyApp.util.Config.getCustomersUrl(). I often need a little more logic in a getter so you can create a getter and try to have a reusable one if possible.

You will also need to set a path and require it:

enabled : true,
paths : {
MyApp : 'app/'


Now you have a config class that you can use app wide.

30 Jan 2012, 10:11 AM
You are always nr. One!
Thanks very much!