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 Answered: How do I get the column name of my grid?

    Answered: How do I get the column name of my grid?


    Everything is in the title :-)

    Thanks.

  2. you can assign an id to your grid columns e.g.

    Code:
    { id: 'column_2008', header: '2008',  dataIndex: '2008', flex:1, hidden: true }
    and then use this id to show or hide columns

    Code:
    for(var i=0; i<selectedYears.length; i++)
    {
      Ext.getCmp('column_' + selectedYears[i]).show();
    }
    In this example, selectedYears would be the array containing the selection of your combobox through which you loop and show only the selected years. You can configure the columns to be hidden by default as shown above.

  3. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,064
    Answers
    110
    Vote Rating
    92
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      0  

    Default


    the question is where do you want to access it...

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

      0  

    Default


    Well, what I want to do is the following:

    I have a multiselect combo with years's value.

    In my grid, I have several columns with the same value so year 2009 is a column, 2010 another and so on...

    When I select a value in my combo I want to keep only this column and hide all others.

    For the moment what I do is to first hide all columns and then display the one I want to keep.
    But as I have many records in the grid, this code is very slow.

    So I would to check if the column name is the same as the values selected in the combo as I can display this column and then hide the others.

    Code:
    if (!combo._isClearingValues)		{
             Global.years = combo.getValue();
             var arrayYears = combo.getValue().toString().split(",");
             valueSelected = arrayYears[arrayYears.length-1];
    
    
            var newYears = new Array();
            if (valueSelected == 'All years' || combo.getValue() == '')
            {
            	newYears.push('All years');
            	combo._isClearingValues = true;
    
    
            	Global.years = '';
            	
            	combo.clearValue();
            	combo.setValue('All years');
            	delete combo._isClearingValues;
            }
            else 
            {
            	for (var i = 0; i < arrayYears.length; i++) {
            		if (arrayYears[i] != 'All years')
            		{
            			newYears.push(arrayYears[i]);
            		}
            	}
    	   	 
       	    	combo._isClearingValues = true;
    
    
            	Global.years = newYears;
            	
            	combo.clearValue();
            	combo.setValue(Global.years);
            	delete combo._isClearingValues;
    }
     		 
    
    
     		 
            if (Global.indicatorGroup == 'TRAPS')
            {	grid = Ext.getCmp('metrSeriesGridId');    //id declared in the grid view
            }
             else if (Global.indicatorGroup == 'NRR')
             {   grid = Ext.getCmp('nrrSeriesGridId');
             }
            
    
    
    		var years = Global.years.toString();
    
    
            var valueArray = years.split(",");
    
    
    		// I set all the column to be visible
    		
    
    
    		alert(valueArray);
    						for (var j = 5; j < 15; j++) {
    			 		grid.columns[j].setVisible(false);
    			 	}
    		for (var i = 0; i < valueArray.length; i++) {
    			//for (var j = 5; j<15; j++)
    			//{
    
    
    			switch (valueArray[i])
    			{
    			 case 'All years':
    			 	for (var i = 5; i < 15; i++) {
    			 		grid.columns[i].setVisible(true);
    			 	}
    			 	break;
    			 case '':
    				for (var i = 5; i < 15; i++) {
    			 		grid.columns[i].setVisible(true);
    			 	}
    			 	break;
    			 case '2002':
    				grid.columns[6].setVisible(true);
    				break;
    			  case '2003':
    				grid.columns[7].setVisible(true);
    				break;
    			  case '2004':
    				grid.columns[8].setVisible(true);
    				break;
    			  case '2005':
    				grid.columns[9].setVisible(true);
    				break;
    			 case '2006':
    				grid.columns[10].setVisible(true);
    				break;
    			  case '2007':
    				grid.columns[11].setVisible(true);
    				break;
    			  case '2008':
    				grid.columns[12].setVisible(true);
    				break;
    			  case '2009':
    				grid.columns[13].setVisible(true);
    				break;
    			  case '2010':
    				grid.columns[14].setVisible(true);
    				break;
    			  default: 
    			  //alert(grid.column.getGridColumns);
    				for (var i = 5; i < 15; i++) {
    				grid.columns[5].setVisible(false);
    				
    				}
    				break;
    				
    		//	}
    			}
    		}
    		}

  5. #4
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,064
    Answers
    110
    Vote Rating
    92
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      0  

    Default


    you can assign an id to your grid columns e.g.

    Code:
    { id: 'column_2008', header: '2008',  dataIndex: '2008', flex:1, hidden: true }
    and then use this id to show or hide columns

    Code:
    for(var i=0; i<selectedYears.length; i++)
    {
      Ext.getCmp('column_' + selectedYears[i]).show();
    }
    In this example, selectedYears would be the array containing the selection of your combobox through which you loop and show only the selected years. You can configure the columns to be hidden by default as shown above.

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

      0  

    Default


    Thanks!
    Quote Originally Posted by Farish View Post
    you can assign an id to your grid columns e.g.

    Code:
    { id: 'column_2008', header: '2008',  dataIndex: '2008', flex:1, hidden: true }
    and then use this id to show or hide columns

    Code:
    for(var i=0; i<selectedYears.length; i++)
    {
      Ext.getCmp('column_' + selectedYears[i]).show();
    }
    In this example, selectedYears would be the array containing the selection of your combobox through which you loop and show only the selected years. You can configure the columns to be hidden by default as shown above.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar