Skip to main content
July 14, 2009
Question

Flash Datagridcolumn visability issue

  • July 14, 2009
  • 2 replies
  • 1741 views

Hey everyone,

I have a datagrid, and need to dynamically hide and show columns. My reading says the .visible property of a column should be able to do this. It does not work. Further reading indicates that I need a patch to fix this issue. However, the patch is for Flex and Flex builder. We do not have either of those projects, we just using Cold Fusion 8. We do not have Flex, or Flash installed. So how can I install this patch, or otherwise resolve this issue? And yes I did do a search on this topic (there were many results) but I could not find a straight forward answer on how to install this patch when you are not using either of the standalone Flex products. Thank you.

This topic has been closed for replies.

2 replies

July 24, 2009

Sure,

When my form loaded I just it call this function

function formOnLoad()

{

            import mx.controls.DataGrid;
            import mx.controls.gridclasses.DataGridColumn;

          _root.RespondentList.getColumnAt(2).visible = false;

          alert(_root.RespondentList.getColumnAt(2).headerText + ' is visible (T or F): ' +_root.RespondentList.getColumnAt(2).visible);

}

It would report that the column was not visible, but it actually was. I also tried with the variant

_root.RespondentList.getColumnAt(2)._visible = false;

but that didn't do any good either. I tried some other variations of that (most too stupid to even note here), but all had the same result, a completly visible column. So I just found a way around it. Basically just find how how many columns I had at the beginning, and add them as needed. Then when I need to change the columns, remove all the old ones (by deleteing from the current count to what the count was at the start) and create the new ones. Less efficient, but it works. If you care, my whole function for that was

          function renameColumns()
          {
          
               // See if there is a number of quota columns defined. If so, delete that many columns, if not, set it to 0
               if(_global.NumberOfDataCols== undefined)
               {
                    _global.NumberOfDataCols = _root.RespondentList.columnCount;
               }
               if(_global.NumberOfQuotaCols == undefined)
               {
                    _global.NumberOfQuotaCols = 0;
                    _global.CriteriaNames = new Array();
                    _global.CriteriaMax = new Array();
               }
               
               else
               {     
                    var TotalCols = _root.RespondentList.columnCount;
                    var StopDeletingAt = _root.RespondentList.columnCount-_global.NumberOfQuotaCols;          
                    for(var i=TotalCols; i>=StopDeletingAt; i--)
                    {
                         _root.RespondentList.removeColumnAt(i);
                    }
               }
                         
               //We need to find how many columns we actually need to create. Best way to do this is to loop over the criteria boxes, as
               //soon as we find an empty one, stop counting.
          
               _global.NumberOfQuotaCols = 0;
          
          
               for(var i=1; i<=10; i++)
               {
                    if(eval("Criteria"+i+".text.length") != 0)
                    {
                         _global.NumberOfQuotaCols++;
               
                         //Create a new column object and set some properties
                         var ColumnName = 'Criteria_'+i+'_Hidden__c';
                         var ColToAdd:DataGridColumn = new DataGridColumn(ColumnName);
                         ColToAdd.width = 100;
                         ColToAdd.headerText = eval('Criteria'+i+'.text');
                         
                         //Store the quota names in an array
                         
                         _global.CriteriaNames[i-1] = eval('Criteria'+i+'.text');
                         _global.CriteriaMax[i-1] = eval('Criteria'+i+'max.text');
                         _root.RespondentList.addColumn(ColToAdd);
                         this["MeetsQuota"+i].visible = true;
                    }
                    else
                    {
                         this["MeetsQuota"+i].visible = false;
                    }
               }
               widenQuotaCols();
               refreshQuotaGrid();                                                            
          }

Of course others would have to customize that heavily to meet their needs.

Cyril Hanquez
Participating Frequently
July 24, 2009

Can you post a short code sample?