1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    64
    Vote Rating
    0
    wasima is on a distinguished road

      0  

    Default Unanswered: Mapping array contents to default controller

    Unanswered: Mapping array contents to default controller


    hi all,
    i have a method here i do mapping of a tab name to a specific controller, for some tabs i have mapped corresponding controller , i want something like " for all the other tabs map 'Summary.DynamicTabController' as the default controller " .
    something like : this.controllerNameMap['all_other_tabs'] = Summary.DynamicTabController';

    Code:
    createControllerMap: function() {
            this.controllerNameMap = new Array();
            this.controllerNameMap['Summary'] = 'Summary.SummaryController';
            this.controllerNameMap['Equipment'] = 'Equipment.EquipmentController';
            this.controllerNameMap['Traffic'] = 'Traffic.TrafficController';
            this.controllerNameMap['Client'] = 'Client.ClientController';
            this.controllerNameMap['RF'] = 'RF.RFController';
            this.controllerNameMap['NewTab1'] = 'Summary.DynamicTabController';     
           
        },
    Pls help me .Thanks in advance

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    828
    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


    So why don't you just have a default mapping? I'm sorry, not really understanding what you are doing or why you can't have a default?
    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
    Dec 2011
    Posts
    64
    Vote Rating
    0
    wasima is on a distinguished road

      0  

    Default


    Hi, Mitchell Simoens,
    Let me try explaining the problem.

    What i mean is i have 5 tabs(Summary,Equipment,Traffic,Client,RF) in my tab panel which are static , now i have an add button in tab panel on clicking which new tabs get added dynamically like NewTab1,NewTab2 etc, to these newly added tabs i need to specify which controller they are mapped to , for all the dynamically added tabs the controller is same 'Summary.DynamicTabController' for all the other 5 static tabs i have specified their controller names manually in this function, so i need to tell this function that if you don't get tab names from one of these 5 static tab names you map the tab name to the default controller that is 'Summary.DynamicTabController'.

    Hope you understood the issue now.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,797
    Answers
    452
    Vote Rating
    602
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    You can just check if the name exists:

    Code:
    var map = {
        summary: 'foo',
        equipment: 'bar'
    };
    
    var a = 'summary';
    var b = 'notthere';
    if (map[a]) {
        console.log(map[a]);
    }
    
    if (!map[b]) {
        //default;
    }
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User
    Join Date
    Dec 2011
    Posts
    64
    Vote Rating
    0
    wasima is on a distinguished road

      0  

    Default


    Thanks evant,
    but newly added tabs have different names like NewTab1,NewTab2 etc.that are generated dynamically .. I cant fix it to just 'nothere' and do mapping .

    Code:
    createControllerMap: function() {
            this.controllerNameMap = new Array();
            var map = {
                Summary: 'Summary.SummaryController',
                Equipment: 'Equipment.EquipmentController',
                Traffic : 'Traffic.TrafficController',
                Client : 'Client.ClientController',
                RF : 'RF.RFController'
            };
            var a = 'Summary';
            var b = 'notthere';
            if (map[a]) {
                console.log(map[a]);
            this.controllerNameMap['Summary'] = 'Summary.SummaryController';
            this.controllerNameMap['Equipment'] = 'Equipment.EquipmentController';
            this.controllerNameMap['Traffic'] = 'Traffic.TrafficController';
            this.controllerNameMap['Client'] = 'Client.ClientController';
            this.controllerNameMap['RF'] = 'RF.RFController';
            }
            else {
                this.controllernamemap['nothere'] = 'summary.DynamicTabController'; // cant do this 'nothere' can be NewTab1,NewTab2 etc
            }

  6. #6
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,114
    Answers
    83
    Vote Rating
    30
    tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about tvanzoelen has a spectacular aura about

      0  

    Default


    I do not see what you want. What is createControllerMap? When is it called?

    But...when registering dynamically new items the most common way is. First register your static stuff in a register

    like you did initial,

    Code:
    createControllerMap: function() {
            this.controllerNameMap = new Array();
            this.controllerNameMap['Summary'] = 'Summary.SummaryController';
            this.controllerNameMap['Equipment'] = 'Equipment.EquipmentController';
            this.controllerNameMap['Traffic'] = 'Traffic.TrafficController';
            this.controllerNameMap['Client'] = 'Client.ClientController';
            this.controllerNameMap['RF'] = 'RF.RFController';   
           
        },
    do you have new items like a tab. Then on render or creation register the controller

    Code:
    tab.on('render', function(c){      
          registerNewTab(c);
    });
    Code:
         registerNewTab: function(tab) {     
            this.controllerNameMap[tab.itemId] = 'Summary.DynamicTabController';       
        },

  7. #7
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,797
    Answers
    452
    Vote Rating
    602
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    That's the point. You declare a map of existing names/controllers.

    If it doesn't exist in the map, then you know to use the default controller.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi