1. #1
    Sencha User
    Join Date
    May 2010
    Location
    Belgium
    Posts
    204
    Answers
    3
    Vote Rating
    1
    marxan is on a distinguished road

      0  

    Default Unanswered: How to use several method in a second controller

    Unanswered: How to use several method in a second controller


    Hello,

    I'm trying to move some methods from my main controller to another controller as it has now too many lines.

    What I do so far:

    In my main controller: I call another controller like this:

    Code:
    'countriescombo': { 
                	change: me.application.getController('Countries').getCountries
                },
    Inside this second controller, I have the following code with 2 methods. The first method is called from the previous piece of code and works. At the end of this method, I try to call the 'filterCountries' method but I must missing something as it doesn't work...

    Code:
    getCountries: function (combo, rec, index, e) {
    		if (!combo._isClearingValues)
    		{
             Global.countries = combo.getValue();
             var arrayCountries = combo.getValue().toString().split(",");
             valueSelected = arrayCountries[arrayCountries.length-1];
    		
           
            if (valueSelected == 'All countries' || combo.getValue() == '')
            {
            	var newCountries = new Array();
            	
            	newCountries.push('All countries');
            	combo._isClearingValues = true;
    
    
            	Global.countries = '';
            	
            	combo.clearValue();
            	combo.setValue('All countries');
            	delete combo._isClearingValues;
            }
            else if (valueSelected == 'All EU countries')
            {
            	var newCountries = new Array();
            	Global.countries = '';
            	
            	newCountries.push('All EU countries');
            	combo._isClearingValues = true;
    
    
    			newCountries.push('Belgium'); newCountries.push('Bulgaria'); newCountries.push('Czech Republic'); newCountries.push('Denmark');
    			newCountries.push('Cyprus'); newCountries.push('Estonia'); newCountries.push('Finland'); newCountries.push('France');
    			newCountries.push('Austria'); newCountries.push('Germany'); newCountries.push('Greece'); newCountries.push('Hungary');
    			newCountries.push('Ireland'); newCountries.push('Italy'); newCountries.push('Latvia'); newCountries.push('Lithuania');
    			newCountries.push('Luxembourg'); newCountries.push('Netherlands'); newCountries.push('Poland'); newCountries.push('Portugal');
    			newCountries.push('Romania'); newCountries.push('Slovakia'); newCountries.push('Slovenia'); newCountries.push('Spain');
    			newCountries.push('Sweden'); newCountries.push('Malta'); newCountries.push('United Kingdom');
            	
            	Global.countries = newCountries;
            	
            	combo.clearValue();
            	combo.setValue('All EU countries');
            	delete combo._isClearingValues;
            }
            else 
            {
            	var newCountries = new Array();
            	Global.countries = '';
            	
            	for (var i = 0; i < arrayCountries.length; i++) {
            		if (arrayCountries[i] != 'All countries' && arrayCountries[i] != 'All EU countries')
            			newCountries.push(arrayCountries[i]);
            	}
    	   	   
    	   	 	combo._isClearingValues = true;
    
    
            	Global.countries = newCountries;
            	
            	combo.clearValue();
            	combo.setValue(Global.countries);
            	delete combo._isClearingValues;
            }
             if (Global.indicatorGroup == 'TRAPS')
    	     {   
    	     	var store = Ext.getStore('MetrSeriesDisplayedStore');
    	     	var storeDetails = Ext.getStore('MetrSeriesDetailsStore');
    	     }
             else if (Global.indicatorGroup == 'NRR')
                var store = Ext.getStore('NrrSeriesStore');
             else if (Global.indicatorGroup == 'TXW')
             {
                var store = Ext.getStore('TaxWedgeDisplayedStore');
                var storeDetails = Ext.getStore('TaxWedge');	
             }
             else if (Global.indicatorGroup == 'SLTXEARN')
                	var store = Ext.getStore('EarningsDisplayedStore');
             else if (Global.indicatorGroup == 'NIDI')
                	var store = Ext.getStore('NidiDisplayedStore');        
             else if (Global.indicatorGroup == 'WB')
                	var store = Ext.getStore('WbDisplayedStore'); 
             else if (Global.indicatorGroup == 'TaxSSC')
                	var store = Ext.getStore('TaxSSCDisplayedStore');    
            
            filterCountries(store);
            filterCountries(storeDetails);
    		}
        },
    
    
    
    
        
        filterCountries: function (store) {
    	//	if (!countries._isClearingValues)
    	//	{
            // If nothing selected, I removed all previously selected filter so I display all datas of my store
            if (Global.countries == '' || Global.countries.toString().match('All countries') != null) {
                store.clearFilter();
                //Ext.getCmp('countryComboId').resetOriginalValue();
            } else {
                // a string that will contain the instruction to evaluate 
                var result;
     
                // I put the selected value of my combo into an Array
                var countr = Global.countries.toString();
                var valueArray = countr.split(",");
     
                //store.filter("LABEISO", countr);
      
                store.filterBy(function (s) {
     
                    //For each value I will concatenate the result value in order to filter on several options   
    
    
                    for (var i = 0; i < valueArray.length; i++) {
                        if (i > 0) {
                            result = result + "|| s.get('LABEISO') =='" + valueArray[i] + "'";
                        } else {
                            result = "(s.get('LABEISO') == '" + valueArray[i] + "'";
                        }
                    }
    
    
                    /* I finish the string to have a string that will be a valid instruction
                     * Example if I selected Belgium and Denmark in my combo list: 
                     * (s.get('LABEISO') == 'Belgium' || s.get('LABEISO') == 'Denmark');
                     */
                    result = result + ");"
     
                    // I evaluate my string to execute it as an instruction
                    return eval(result);
                });
            }
        }
    Thanks for any help.

    Regards

  2. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Try to fix your code as below:
    Code:
        ...
        //filterCountries(store);
        //filterCountries(storeDetails);
        this.filterCountries(store);
        this.filterCountries(storeDetails);

  3. #3
    Sencha User
    Join Date
    May 2010
    Location
    Belgium
    Posts
    204
    Answers
    3
    Vote Rating
    1
    marxan is on a distinguished road

      0  

    Default


    Hi, thanks for your answer. I've already tried this but it doesn't work. It seems that the 'this' is linked to the main component.

    Quote Originally Posted by vietits View Post
    Try to fix your code as below:
    Code:
        ...
        //filterCountries(store);
        //filterCountries(storeDetails);
        this.filterCountries(store);
        this.filterCountries(storeDetails);

  4. #4
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Try to fix method calling like this:
    Code:
    'countriescombo': { 
        //change: me.application.getController('Countries').getCountries
        change: function(){
            var controller = me.application.getController('Countries');
            controller.getCountries.apply(controller, arguments);
        }
    },

Thread Participants: 1

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