5 Replies Latest reply on Sep 21, 2010 10:50 AM by Flex harUI

    Fetching column data for clicked DataGrid cell

    Chuckle12345

      I am using a DataGrid and the number of columns are based on the data thus dynamic; columns are added at runtime.  I am trying to use the same ItemRenderer for all columns.  The one piece I can not seem to get to work is knowing which datafield to use to populate each column.  I have tried getting the column.dataField from the current datacolumn to no avail; sample code listed below.  This is my first Flex project so my approach to the problem may not be the best; please alert me if this is the case.  I would appreciate any help you could lend.

       

       

                      var dgListData:DataGridListData = listData as DataGridListData;
                      var dataGrid:DataGrid = dgListData.owner as DataGrid;
                      var column:DataGridColumn = dataGrid.columns[dgListData.columnIndex];
                      var dataField = column.dataField;

                                     
                      var lbl:Label = new Label();
                      lbl.text = value[dataField];    // must add based on previously named source field; dataField

       

       

      ce