3 Replies Latest reply on Feb 28, 2007 7:29 AM by peterent

    Append Records From DataGrid

    wy790289
      Hi All,

      When a dataGrid is in edit mode, it can modify its existing data. Is it possible to let the data grid to append a record when users press the "down" arrow key on the last grid record, or do the some action in any easy ways.

      Thanks,
      Wilson
        • 1. Re: Append Records From DataGrid
          peterent Level 2
          You can intercept the itemEditEnd event and decide what to do at that point.
          • 2. Re: Append Records From DataGrid
            wy790289 Level 1
            Hi Pete,

            Thanks for your help! But I still don't know how to do it. e.g. how to insert a blank row to dataGrid and detect the key that user pressed. Could you please advise where can I find the details information about this?

            Thanks,
            Wilson
            • 3. Re: Append Records From DataGrid
              peterent Level 2
              You don't insert a blank row into the DataGrid, you insert an empty record into the collection that's being used as the dataProvider to the DataGrid. The DataGrid is watching for changes to its dataProvider and will act accordingly.

              [Bindable] private var dp:ArrayCollection = new ArrayCollection();
              ...
              <mx:DataGrid dataProvider="{dp}" ...>
              ...
              </mx:DataGrid>

              If you then do: dp.addItem( someobject ); where someobject has the properties (with empty values) corresponding the dataFields on the DataGrid's DataGridColumns, addItem will stick the someobject onto the end of the collection and the DataGrid will suddenly have an empty row added to it.