2 Replies Latest reply on Mar 8, 2008 4:57 AM by kkirankumar

    Rendering DataGrid items using ActionScript


      I would like to add columns to a DataGrid using ActionScript. I would also like to add a CheckBox as one of the columns in the DataGrid.

        • 1. Re: Rendering DataGrid items using ActionScript
          Gregory Lafrance Level 6
          This code could be improved upon, but here goes:

          <?xml version="1.0"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" initialize="init()">
          import mx.controls.DataGrid;
          import mx.controls.dataGridClasses.DataGridColumn;
          import mx.collections.ArrayCollection;

          private var dg:DataGrid;

          private function init():void{
          var ac:ArrayCollection = new ArrayCollection([{Artist:"Pavement",Price:"11.99",
          Album:"Slanted and Enchanted"}, {Artist:"Pavement",
          Album:"Brighten the Corners",Price:"11.99"}]);
          dg = new DataGrid();
          dg.dataProvider = ac;
          var dg_album:DataGridColumn = new DataGridColumn();
          dg_album.dataField = "Album";
          var dg_price:DataGridColumn = new DataGridColumn();
          dg_price.dataField = "Price";

          • 2. Re: Rendering DataGrid items using ActionScript
            kkirankumar Level 1
            Thanks for the quick reply. However, I would like to know why I can't set the id property for the CheckBox in the following case. I would like to set the Id property of the CheckBox like I am setting the dataField property. In the below example I am using the dataField "action".

            <mx:DataGridColumn headerText="" dataField="action" width="20" resizable="false">
            <mx:CheckBox id="{action}" label=""/>