1 Reply Latest reply on Aug 4, 2008 4:49 PM by Gregory Lafrance

    Adding Rows to  a Datagrid

    nash99
      Hi ,
      I am trying to add a new row (editable) with text in 1 column and a button in the other column of the datagrid---
      At a specified location (like if I select a row and hit the add button I should be able to add a row below this selected row)
      Also I should be able to get the location of the button in the datagrid .
      I tried using this code but it doesnt serve the purpose

      <mx:Button id="addRowBtn" label="ADD" click="handleAddEvent(event,addRowBtn,subLevelGrid)" y="1" x="80"/>

      <mx:Script>
      <![CDATA[

      public function handleAddEvent(event:MouseEvent,button:Button,dataGrid:DataGrid):void{

      if(!(dataGrid.isItemSelected(event)))
      {

      Alert.show('dataGrid selected row is ' + dataGrid.selectedIndex);

      subLevelGrid.dataProvider.addItem({"title":"nnnnn"});
      }

      if(dataGrid.isItemSelected(event))
      {

      Alert.show('dataGrid selected row is ' + dataGrid.selectedIndex);

      subLevelGrid.dataProvider.addItemAt({"title":"hhhhh"},dataGrid.selectedIndex);
      }

      }
      ]]>
      </mx:Script>