2 Replies Latest reply on Oct 23, 2009 4:06 AM by timo888

    myDataGridColumn.visible in ActionScript?


      Is myDataGridColumn.visible=false in ActionScript the equivalent of mxml  visible="false"?  The grid is ignoring my explicit column creation and using whatever columns appear in the underlying dataProvider (an ArrayCollection).


      Although I've set it to be invisible, the column below ("wrdid") is visible on my CheckBoxDataGrid when the grid is instantiated in AS.  I've seen references in postings from 2007 to a hotfix that fixed problems with column visibility. Is this still a known issue (I downloaded the trial just a couple of weeks ago and assume it included any hotfixes that old) or am I doing something incorrectly in the code below?




                  var idcol:DataGridColumn = new DataGridColumn;
                  idcol.visible=false;   // but this column is VISIBLE
                  idcol.headerText="id";  //  <-- commenting this line out makes no difference
                  var wordcol:DataGridColumn=new DataGridColumn;

        • 1. Re: myDataGridColumn.visible in ActionScript?
          paul.williams Level 4

          The "columns" property getter returns a copy of the datagrid's columns array, so pushing new columns into it won't work. You need to explicitly reassign the columns property with a new array.

          • 2. Re: myDataGridColumn.visible in ActionScript?
            timo888 Level 1

            Thank you! I've been consulting the LangRef and the DevGuide, neither of which mentioned this IIRC. But I just looked into the source code of the DataGrid class itself (I'm coming from .NET so I've gotten used to working with black-boxes and it did not occur to me to look for clues there )  and there indeed it says this:


            If you want to change the set of columns, you must get this array,
            make modifications to the columns and order of columns in the array,
            and then assign the new array to the columns property.  This is because
            the DataGrid control returned a new copy of the array of columns and therefore
            did not notice the changes.