1. #1
    Sencha User
    Join Date
    Aug 2011
    Location
    Brescia - Italy
    Posts
    102
    Vote Rating
    4
    tino7_03 is on a distinguished road

      0  

    Default Dinamic url in MVC app Store

    Dinamic url in MVC app Store


    Is there a way to define a store in a MVC app with a dinamic url like this?
    PHP Code:
    Ext.define('GpMobile.store.Customers', {
        
    extend'Ext.data.Store',
        
    config:{        
                      
    model'GpMobile.model.Customers',        
                      
    timeout 3000,        
                      
    proxy : {           
                                  
    urlthis.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',
                                  
    clearOnPageLoadfalse,
                                  
    reader:{
                                               
    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

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,074
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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...

    Code:
    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:

    Code:
    Ext.Loader.setConfig({
        enabled : true,
        paths : {
            MyApp : 'app/'
        }
    });
    
    Ext.require([
        'MyApp.util.Config'
    ]);
    Now you have a config class that you can use app wide.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Aug 2011
    Location
    Brescia - Italy
    Posts
    102
    Vote Rating
    4
    tino7_03 is on a distinguished road

      0  

    Default


    You are always nr. One!
    Thanks very much!

Thread Participants: 1