Hybrid View

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    40
    Vote Rating
    0
    pkvenu is on a distinguished road

      0  

    Default Answered: Create a config file

    Answered: Create a config file


    Hi guys,

    can some one tell me how to create a config file so that i could use it across the application.

    In JavaScript i would create a file called config and

    Code:
    ar mapserviceUrl1 = "http://204.94.80.163/ArcGIS/rest/services/";
    var mapserviceUrl = "http://map1-2.lan.511.org/ArcGIS/rest/services/";
    //var localImageDir = mapImageDirectory;
    
    
    function mapConfig() { };
    var mapconfig = new mapConfig();
    //mapConfig.prototype.LocalImageDir = localImageDir;
    
    mapConfig.prototype.generalSettings = {
        defaultZoomLevel: 2, 
        defaultQueryTolerancePixels:2
    }
    
    mapConfig.prototype.generalSettings = {
        defaultZoomLevel: 2,
        defaultQueryTolerancePixels: 2
    };
    
    mapConfig.prototype.spatialReference = {
        parking: new esri.SpatialReference({ wkid: 4269 })
    };
    and then call mapconfig.generalSetting to get the general setting values in my application.

    How can i perform the same in sencha touch 2

    Regards,
    Paw

  2. You can still create a config file and include it as a <script> tag in your index.html file. The namespace won't be setup if you are wanting to use a namespace like in the MVC. If you are using MVC, I personally create a singleton that I require first...

    Code:
    Ext.define('MyApp.Config', {
        singleton : true,
    
        config : {
            urls : {
                users : 'users/get.php'
            }
        }
    });
    Above your Ext.application call you can then use Ext.require to load this file:

    Code:
    Ext.Loader.setPath('MyApp', 'app');
    
    Ext.require([
        'MyApp.Config'
    ]);
    Within your application classes you can get a url via:

    Code:
    MyApp.Config.getUrls().users

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,549
    Vote Rating
    873
    Answers
    3567
    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


    You can still create a config file and include it as a <script> tag in your index.html file. The namespace won't be setup if you are wanting to use a namespace like in the MVC. If you are using MVC, I personally create a singleton that I require first...

    Code:
    Ext.define('MyApp.Config', {
        singleton : true,
    
        config : {
            urls : {
                users : 'users/get.php'
            }
        }
    });
    Above your Ext.application call you can then use Ext.require to load this file:

    Code:
    Ext.Loader.setPath('MyApp', 'app');
    
    Ext.require([
        'MyApp.Config'
    ]);
    Within your application classes you can get a url via:

    Code:
    MyApp.Config.getUrls().users
    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.

  4. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    40
    Vote Rating
    0
    pkvenu is on a distinguished road

      0  

    Default


    This is what i was looking for. Thanks.

    I was trying to do some thing like this which worked but was not sure.

    Code:
    Ext.define('Utils.parkingMapConfig', {
        statics: {
            generalSettings: {
                defaultZoomLevel: 2,
                defaultQueryTolerancePixels: 2
            },
            spatialReference: {
                parking: new esri.SpatialReference({ wkid: 4269 })
            },
            mapService: {
                baseMapTileSTANDARD: "http://204.94.80.163/ArcGIS/rest/services/MMTPBaseMap/MapServer",
                blockFace: "http://map2-2.lan.511.org/ArcGIS/rest/services/UPPParking/MapServer"
    
            },
            streetParkingLayers: {
                Zones: [6, 8, 10],
                BlockFaces: [1, 3, 5],
                Both: [1, 3, 5, 6, 8, 10]
    
            },
            dynamicLayerList: [
                                    "blockFace,http://map2-2.lan.511.org/ArcGIS/rest/services/UPPParking/MapServer"
                                ],
            baseLayerList: [
                                     "baseMapTileSTANDARD,http://204.94.80.163/ArcGIS/rest/services/MMTPBaseMap/MapServer" 
                               ],
            blockFaceZoomLevelQueryTolerance: {
                0: 3,
                1: 3,
                2: 4,
                3: 4,
                4: 5,
                5: 8,
                6: 9,
                7: 15,
                8: 10,
                9: 10,
                10: 10,
                11: 10
            }
        },
            constructor: function (config) {
                this.initConfig(config);
                // the 'self' property of an instance refers to its class
                this.self;
            }
        
    });
    Thanks once again

  5. #4
    Sencha User
    Join Date
    Apr 2012
    Location
    Linz, AT
    Posts
    31
    Vote Rating
    1
    Answers
    1
    drindal is on a distinguished road

      0  

    Default set users

    set users


    Hi!

    How can I set urls.users in your example?
    Code:
     MyApp.Config.getUrls().users
    doesn't work of course..

    Sorry for kidnapping your thread

  6. #5
    Sencha User
    Join Date
    Aug 2011
    Location
    London
    Posts
    409
    Vote Rating
    18
    Answers
    18
    digeridoopoo will become famous soon enough

      0  

    Default Take a look at the Anthologia app example....

    Take a look at the Anthologia app example....


    For a working example take a look at the Anthologia magazine app example in examples and showcases part of the forum

    :-)

  7. #6
    Sencha User
    Join Date
    Apr 2012
    Location
    Linz, AT
    Posts
    31
    Vote Rating
    1
    Answers
    1
    drindal is on a distinguished road

      0  

    Default


    Thanks! The advice to look at the showcases was really good. In the Ux.locale.Manager showcase I found the solution to my problem!