0 Replies Latest reply on Nov 7, 2011 3:31 AM by nezar71

    replace cell content with another clell in spark datagrid

    nezar71 Level 1

      I have a quiz application in flex 4.5 i want code for button when i click it make the answer i selected (answer2 or answer3) from DataGrid cell replaced by (answer1) and (answer1) cell  replaced by (cell of answer i selected)

      this is the code

       

      i make DataGrid editable and selection Mode="singleCell"

       

       

          <?xml version="1.0" encoding="utf-8"?>

      <s:Application

          xmlns:fx="http://ns.adobe.com/mxml/2009"

          xmlns:s="library://ns.adobe.com/flex/spark">

         

          <fx:Script>

             

              <![CDATA[

                  import mx.collections.IList;

                 

                  [Bindable]

                  public var gridData:IList = new ArrayList([{Question: "how many", answer1: "five", answer2: "three", answer3: "two"},

                      // ... more similar objects

                  ]);

                 

                  protected function button1_clickHandler(event:MouseEvent):void

                  {

                 

                  }

              ]]>

             

          </fx:Script>

         

          <s:DataGrid id="dataGrid" x="59" y="68" width="556" height="228" dataProvider="{gridData}"

                      editable="true"

                      selectionMode="singleCell">

              <s:columns>

                  <s:ArrayList>

                      <s:GridColumn dataField="Question"/>

                      <s:GridColumn dataField="answer1"/>

                      <s:GridColumn dataField="answer2"/>

                      <s:GridColumn dataField="answer3"/>

                  </s:ArrayList>

              </s:columns>

          </s:DataGrid>

          <s:Button x="236" y="10" label="MakeIt it Answer1" click="button1_clickHandler(event)"/>

      </s:Application>