I managed to achieve what I want using a bit of code. If anyone's intersted.

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
                           xmlns:s="library://ns.adobe.com/flex/spark"
                           xmlns:mx="library://ns.adobe.com/flex/mx" 
minWidth="955" minHeight="600">
 <s:layout>
        <s:VerticalLayout horizontalAlign="center" paddingTop="10"/>
 </s:layout>

 <!--I'm mimiking the row locking by using selectedIndex, caretChange, and a 
few colors
 -->

 <fx:Declarations>
<!-- Place non-visual elements(e.g., services, value objects) here -->
 </fx:Declarations>

 <fx:Script>
   <![CDATA[
        import mx.collections.ArrayCollection;
        import spark.events.GridCaretEvent;
        import spark.events.GridEvent;
        import spark.events.GridItemEditorEvent;

        [Bindable]
        private var myDP:ArrayCollection = new ArrayCollection([
                        {col0:"something", col1:4, col2:'goes', col3:'in', 
col4:'here'},{col0:"maybe", col1:3, col2:'this', col3:'one', col4:'as 
well'},{col0:"what", col1:1, col2:'about', col3:'this', col4:'one'},{col0:"sean 
paul", col1:3, col2:'red', col3:'temperature', col4:'um'},{col0:"chaka demus", 
col1:3, col2:'green', col3:'and pliers', col4:'um'}]);

        private var savedRowIndex:int = -1;

        private function lockRow():void
        {
          dg.editable = true;
          this.savedRowIndex = dg.selectedIndex;
          dg.setStyle("rollOverColor", 0xffffff);
          dg.setStyle("caretColor", 0xffffff);
          dg.addEventListener(GridCaretEvent.CARET_CHANGE, 
dg_caretChangeHandler);
        }
        private function unlockRow():void
        {
          dg.editable = false;
          this.savedRowIndex = -1;
          dg.setStyle("rollOverColor", 0xCEDBEF); //default spark rollOverColor 
= 0xCEDBEF
          dg.setStyle("caretColor", 0xA8C6EE); //default spark selectionColor = 
0xA8C6EE
        dg.removeEventListener(GridCaretEvent.CARET_CHANGE, 
dg_caretChangeHandler);
        }

protected function 
dg_gridItemEditorSessionStartingHandler(event:GridItemEditorEvent):void
        {
        // If you tab to last editable column -> I want to setFocus on the 
button
        if(event.rowIndex != dg.selectedIndex)//or may event.rowIndex == 
dg.selectedIndex+1
        {
                event.preventDefault();
                callLater(btn1.setFocus);
                return;
        }
        }

protected function dg_caretChangeHandler(event:GridCaretEvent):void
        {
        // This handler gets called before gridClick...so I can use it to stay 
focused on one row
        if(this.savedRowIndex != -1)
        {
        dg.selectedIndex = this.savedRowIndex;
        return;
        }
}

        ]]>
        </fx:Script>

        <s:Label text="Select a row. The lock (or unlock) the row. You 
shouldn't be able to click (or tab) anything else"/>

        <s:DataGrid id="dg" dataProvider="{myDP}" width="50%"           
gridItemEditorSessionStarting="dg_gridItemEditorSessionStartingHandler(event)">
        <s:columns>
         <s:ArrayList>
            <s:GridColumn dataField="col0" headerText="col0"/>
            <s:GridColumn dataField="col1" headerText="col1"/>
            <s:GridColumn dataField="col2" headerText="col2"/>
             <s:GridColumn dataField="col3" headerText="col3"/>
             <s:GridColumn dataField="col4" headerText="col4"/>
        </s:ArrayList>
                </s:columns>
        </s:DataGrid>
        <s:HGroup>
         <s:Button id="btn1" label="lock row" click="lockRow()" />
          <s:Button id="btn2" label="unlock row" click="unlockRow()"/>
        </s:HGroup>
</s:Application>


--- In flexcoders@yahoogroups.com, "bhaq1972" <mbhaque@...> wrote:
>
> We'd prefer to stay within the datagrid.
> 
> 
> --- In flexcoders@yahoogroups.com, Rishi Tandon <rishitandon123@> wrote:
> >
> > Make a pop up window which include the searchable row based on some unique 
> > ID and then display the row field and data inside a form.
> > 
> > After changing the field value, update the grid data provider with the 
> > changed row value.
> > 
> > Sent from my iPhone
> > 
> > On Aug 24, 2011, at 10:56 PM, "Amy" <amyblankenship@> wrote:
> > 
> > > How would a user edit a row that is not selected?
> > > 
> > > --- In flexcoders@yahoogroups.com, "bhaq1972" <mbhaque@> wrote:
> > > >
> > > > How would I go about making the datagrid.selectedItem the ONLY editable 
> > > > row?
> > > > 
> > > > A bit like making individual columns editable by setting 
> > > > GridColumn.editable.
> > > > 
> > > > Thanks
> > > > 
> > > > BH
> > > >
> > > 
> > >
> >
>


Reply via email to