1 Reply Latest reply on Feb 21, 2007 10:57 AM by michael_ramirez44

    Returns column name of DataGrid

    nprzybylo
      How can I get the column name of a selected cell in a DataGrid? I have a change event handler of type Event where I want to determine which column was clicked.
        • 1. Re: Returns column name of DataGrid
          michael_ramirez44 Level 1
          Use the itemEditBeginning event on your DataGrid. The itemEditBeginning event is only dispatched if your DataGrid is editable so set editable to true. In the event handler for itemEditBeginning call the events preventDefaults method to prevent the DataGrid from create a TextInput control for that cell.

          <mx:DataGrid id="dg" dataProvider="{myData}" itemEditBeginning="editDataGrid(event)" editable="true">
          ..
          public function editDataGrid(event:DataGridEvent):void
          {
          event.preventDefault();
          Alert.show("Column: " + dg.columns[event.columnIndex].headerText, "");
          }