2 Replies Latest reply on Jan 25, 2010 3:56 AM by Markus Häcki

    AdvancedDataGrid problem with programmatically adding a column

    Markus Häcki

      Hi everybody,

      I have a Problem with adding columns programmatically to a AdvancedDataGrid. The code:

       

      var cols:Array = thisDataGrid.columns;
      cols.push(dgc);
      thisDataGrid.columns = cols;
      
      
      
      

      does create a column, adds it to the cols array, bot the last code line has no effect. The cols wont be found in the thisDataGrid.columns property...

      What could be the problem? I'm working with a test license, and on the advanceddatagrid the watermark shows up. Could this be a problem?

      Thanks for help!

      Markus

        • 1. Re: AdvancedDataGrid problem with programmatically adding a column
          archemedia Level 4

          As the columns property of an adg is bindable, you could try to bind it to an array and afterwards, add columns to that array:

           

          AS:

          [Bindable]
          private var adgCols:Array = new Array();

           

          private function addCol():void
                      {
                          var myCol:AdvancedDataGridColumn = new AdvancedDataGridColumn();
                          myCol.headerText = "test";
                          myCol.dataField = "v1";
                          adgCols.push(myCol);
                      }

           

          MXML:

          <mx:AdvancedDataGrid id="adg" designViewDataType="flat" columns="{adgCols}"/>

           

          This helps?

           

          Dany

          • 2. Re: AdvancedDataGrid problem with programmatically adding a column
            Markus Häcki Level 1

            Hi Dany,

             

            Thanks for your answer! I realized, that I better use the normal datagrid. Its more effizient, and also fits my needs!

             

            It would bee quite complicated to test your solution now, as I changed a lot since I posted this question...

             

            Never the less, thanks a lot!

            Markus