1 Reply Latest reply on Feb 3, 2011 4:00 PM by kevinklin

    Populating a Forum froma  data grid in Flex

    Adrien. Level 1

      I have a forum that I would like to pouplate to be able to edit the information in Flex (flash builder four). So how would I click on a row of data (from a datagrid) and have it populate the forum?

        • 1. Re: Populating a Forum froma  data grid in Flex
          kevinklin Adobe Employee



          Do you mean a Form? Try listening for the "gridClick" event on the DataGrid and looking at the "item" property of the event. This event dispatches when the user clicks on the DataGrid and item will be the data object from the row that the user clicks on. I've written up a simple example below:


          <?xml version="1.0" encoding="utf-8"?>
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                         xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
                  <s:VerticalLayout gap="10" paddingTop="10" paddingRight="10" />
                      import spark.events.GridEvent;
                      protected function dataGrid_gridClickHandler(event:GridEvent):void
                          var item:Object = event.item;
                          if (item)
                              keyTI.text = item.key;
                              nameTI.text = item.name;
              <s:DataGrid id="dataGrid" gridClick="dataGrid_gridClickHandler(event)">
                      <fx:Object key="1000" name="Abrasive" />
                      <fx:Object key="1001" name="Brush"/>
                      <fx:Object key="1002" name="Clamp"/>
                      <fx:Object key="1003" name="Drill"/>
                      <fx:Object key="1004" name="Epoxy"/>
                      <fx:Object key="1005" name="File" />
                      <fx:Object key="1006" name="Gouge"/>
                      <fx:Object key="1007" name="Hook"/>
                      <fx:Object key="1008" name="Ink" />
                      <fx:Object key="1009" name="Jack" />             
                  <s:FormItem label="key">
                      <s:TextInput id="keyTI" />
                  <s:FormItem label="name">
                      <s:TextInput id="nameTI" />


          Of course, you'll have to write some code so that the you can edit the data and save it from the Form. Hope this helps.