Hi Arun,

Here you go... I have made it in both ways, i.e. by click of a button in the
itemRenderer and also by selecting a row...

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; width="800">
    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.events.ListEvent;
            import mx.collections.ArrayCollection;
            [Bindable] private var employees:ArrayCollection = new
ArrayCollection([{"name":"Christina
Coenraets","phone":"555-219-2270","email":"[EMAIL 
PROTECTED]","active":"true"},{"name":"Joanne
Wall","phone":"555-219-2012","email":"[EMAIL 
PROTECTED]","active":"true"},{"name":"Maurice
Smith","phone":"555-219-2012","email":"[EMAIL 
PROTECTED]","active":"false"},{"name":"Mary
Jones","phone":"555-219-2000","email":"[EMAIL PROTECTED]","active":"true"}]);


            private function dgItemClick(event:ListEvent):void{
                if (event.columnIndex != 3) //to check if the button has not
been clicked
                    loadItem(event.itemRenderer.data);
            }

            public function loadItem(dataObj:Object):void{
                var str:String = "";
                for (var items:String in dataObj)
                {
                    if (items != "mx_internal_uid")//this is an extra unique
id that Flex assigns by itself
                        str += items + ":" + dataObj[items] + "\n";
                }
                Alert.show(str);
            }
        ]]>
    </mx:Script>


        <mx:DataGrid id="dg" width="500" height="200" rowCount="5"
dataProvider="{employees}" itemClick="dgItemClick(event)">
            <mx:columns>
                <mx:DataGridColumn dataField="name" headerText="Name"/>
                <mx:DataGridColumn dataField="phone" headerText="Phone"/>
                <mx:DataGridColumn dataField="email" headerText="Email"/>
                <mx:DataGridColumn headerText="">
                    <mx:itemRenderer>
                        <mx:Component>
                            <mx:Button label="Select"
click="{outerDocument.loadItem(data)}"/>
                        </mx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>
            </mx:columns>
        </mx:DataGrid>

</mx:Application>

Regards,
Venkat
www.venkatv.com

On Thu, Oct 9, 2008 at 7:28 AM, Arun <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I am thinking of getting the values based on the row clicked by the
> user.
> I am not sure how to retrieve a row from a ArrayCollection based on
> the row id though.
>
> Would it be possible to provide a sample code?
>
> Thanks
>
> On Oct 9, 1:14 am, "Venkat Viswanathan" <[EMAIL PROTECTED]> wrote:
> > Hi Arun,
> >
> > You can keep the unique ID. But if you want then you can get the object
> for
> > the specific row anyways. On click of the button, you can send the
> variable
> > "data" to the required method, and you will get all the fields of that
> > specific row.
> >
> > Regards,
> > Venkatwww.venkatv.com
> >
> > On Tue, Oct 7, 2008 at 7:53 AM, Arun <[EMAIL PROTECTED]> wrote:
> >
> > > Hello,
> >
> > > I have a datagrid and the datagrid dataProvider is an ArrayCollection.
> >
> > > So I was thinking if it is possible to add a unique id to the array
> > > collection,assign the unique id to the dataprovider as some kind of a
> > > hidden field. When I invoke the edit button, I will try get all the
> > > values from the same array which i used in for the datagrid. My idea
> > > is to get the row from the array based on the unique id.
> >
> > > I do not have much control with the source of the data.
> >
> > > Any other ideas are welcome.
> >
> > > Thanks
> >
> > > Arun
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to