RE: [flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column index
yourDataGrid.addEventListener(ListEvent.ITEM_CLICK, setColumnCopy); function setColumnCopy(){ _selectedCol = yourDataGrid.columns[event.columnIndex].dataField; Alert.show(yourDataGrid.selectedItem[_selectedCol]); } -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of helihobby Sent: Monday, February 26, 2007 11:25 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column index Thank you all for the answers ... The problem is that I need to know which cell he clicked on. Or in other words, what is the text that displayed on that cell... Getting the complete ArrayCollection object which the user clicked on is easy as I can ( as u guys mentioned ) simply grab the event and do event.selectedItem.SOME_PROP_HERE However, I need to know which prop he clicked on as during runtime I do not know the name of SOME_PROP_HERE. In my case I have over 40 columns per row and each carries the name of Open1 Open2 Open3 Open4 . etc ... So of course doing event.selectedItem.Open1 will work. But how do I know if clicked on the column Open1 or Open2 or Open3 etc ... I need to figure out which OpenN ( N = number ) he clicked on ... Thanks again, Sean. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , helihobby [EMAIL PROTECTED] wrote: Hello, Can anyone help out ... I know the Data Grid Cell's Row and Colum Index. How can I retrieve the data in that cell if I know these two values ? Thank you, Sean.
[flexcoders] Re: Can anyone help on getting data from a grid cell
a complete sample: - ?xml version=1.0? !-- DataGrid control example. -- mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; initialize=initApp() mx:Script![CDATA[ import mx.controls.Alert; import mx.events.ListEvent; private function initApp():void{ dg.addEventListener(ListEvent.ITEM_CLICK,setColumnCopy) ; } private function setColumnCopy(event:ListEvent):void{ var _selectedCol:Object = dg.columns[event.columnIndex].dataField; Alert.show(dg.selectedItem[_selectedCol]); } ]]/mx:Script mx:XMLList id=employees employee nameChristina Coenraets/name phone555-219-2270/phone email[EMAIL PROTECTED]/email activetrue/active /employee employee nameJoanne Wall/name phone555-219-2012/phone email[EMAIL PROTECTED]/email activetrue/active /employee employee nameMaurice Smith/name phone555-219-2012/phone email[EMAIL PROTECTED]/email activefalse/active /employee employee nameMary Jones/name phone555-219-2000/phone email[EMAIL PROTECTED]/email activetrue/active /employee /mx:XMLList mx:Panel title=DataGrid Control Example height=100% width=100% paddingTop=10 paddingLeft=10 paddingRight=10 mx:Label width=100% color=blue text=Select a row in the DataGrid control./ mx:DataGrid id=dg width=100% height=100% rowCount=5 dataProvider={employees} mx:columns mx:DataGridColumn dataField=name headerText=Name/ mx:DataGridColumn dataField=phone headerText=Phone/ mx:DataGridColumn dataField=email headerText=Email/ /mx:columns /mx:DataGrid mx:Form width=100% height=100% mx:FormItem label=Name mx:Label text={dg.selectedItem.name}/ /mx:FormItem mx:FormItem label=Email mx:Label text={dg.selectedItem.email}/ /mx:FormItem mx:FormItem label=Phone mx:Label text={dg.selectedItem.phone}/ /mx:FormItem /mx:Form /mx:Panel /mx:Application - - Original Message From: helihobby [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Tuesday, February 27, 2007 10:25:58 AM Subject: [flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column index Found the solution from a guy who emailed me ... thx This is what worked for me: yourDataGrid. addEventListener (ListEvent. ITEM_CLICK, setColumnCopy) ; function setColumnCopy( ){ _selectedCol = yourDataGrid. columns[event. columnIndex] .dataField; Alert.show(yourData Grid.selectedIte m[_selectedCol] ); } As always, Thank you for all the help and support. BRA HREF=http://www.helihobb y.com/html/ alon_desingpatte rn.htmlFONT SIZE=-1 FACE=Verdana, Tahoma,Arial, Helvetica, Sans-serif Read my solution for Flex Component communication here.../FONT /A BRSean - A HREF=http://www.helihobb y.comFONT SIZE=-1 FACE=Verdana, Tahoma,Arial, Helvetica, Sans-serif HeliHobby. com/FONT Finding fabulous fares is fun. Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains. http://farechase.yahoo.com/promo-generic-14795097
[flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column index
Hi Sean, you can do it by calling a method on itemClick of a dataGrid. in this method you'll get the selected row of your Grid. thereafter you can access any particular cell's value by specifying dataField name like: evt.target.selectedItem.DataFieldNAME; -- In flexcoders@yahoogroups.com, helihobby [EMAIL PROTECTED] wrote: Is it possible ? Sean. --- In flexcoders@yahoogroups.com, helihobby helihobby@ wrote: Hello, Can anyone help out ... I know the Data Grid Cell's Row and Colum Index. How can I retrieve the data in that cell if I know these two values ? Thank you, Sean.
Re: [flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column index
It's not usual to access data from the grid, you access data from it's dataprovider that is normally either a ArrayCollection or a XML object. Imagine your grid has the following data provider: var xml:XML = package employee id=0 name=Michael/ employee id=1 name=Roger/ /package; So you can access data this way: [EMAIL PROTECTED] will return Roger. [EMAIL PROTECTED] will return 0 On 2/26/07, helihobby [EMAIL PROTECTED] wrote: Is it possible ? Sean. --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, helihobby [EMAIL PROTECTED] wrote: Hello, Can anyone help out ... I know the Data Grid Cell's Row and Colum Index. How can I retrieve the data in that cell if I know these two values ? Thank you, Sean. -- André Rodrigues Pena LOCUS www.locus.com.br Blog www.techbreak.org
[flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column index
Thank you all for the answers ... The problem is that I need to know which cell he clicked on. Or in other words, what is the text that displayed on that cell... Getting the complete ArrayCollection object which the user clicked on is easy as I can ( as u guys mentioned ) simply grab the event and do event.selectedItem.SOME_PROP_HERE However, I need to know which prop he clicked on as during runtime I do not know the name of SOME_PROP_HERE. In my case I have over 40 columns per row and each carries the name of Open1 Open2 Open3 Open4 . etc ... So of course doing event.selectedItem.Open1 will work. But how do I know if clicked on the column Open1 or Open2 or Open3 etc ... I need to figure out which OpenN ( N = number ) he clicked on ... Thanks again, Sean. --- In flexcoders@yahoogroups.com, helihobby [EMAIL PROTECTED] wrote: Hello, Can anyone help out ... I know the Data Grid Cell's Row and Colum Index. How can I retrieve the data in that cell if I know these two values ? Thank you, Sean.
Re: [flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column index
OMG i just realized I just gave you the reverse of what you are asking for haha. my bad. anyway, try using datagrid's indicesToIndex() method. It will return the index (in your dataprovider)... I assume you can then look up your dataprovider to determine which item/prop/text is which? :) Cheers! -leds --- leds usop [EMAIL PROTECTED] wrote: Hi listen for the itemclickevent and then use specifically ListEvent as the event type paramter of the listener then use the rowIndex and columnindex properties like so: private function test(e:ListEvent):void{ trace(e.rowIndex.toString()); trace(e.columnIndex.toString()); } be aware however that these indeces are relative to the visual grid, hence the headers (if you use them) are counted. Just compensate approprately.. like subtract 1 from the rowindex. :) Cheers! -leds --- helihobby [EMAIL PROTECTED] wrote: Thank you all for the answers ... The problem is that I need to know which cell he clicked on. Or in other words, what is the text that displayed on that cell... Getting the complete ArrayCollection object which the user clicked on is easy as I can ( as u guys mentioned ) simply grab the event and do event.selectedItem.SOME_PROP_HERE However, I need to know which prop he clicked on as during runtime I do not know the name of SOME_PROP_HERE. In my case I have over 40 columns per row and each carries the name of Open1 Open2 Open3 Open4 . etc ... So of course doing event.selectedItem.Open1 will work. But how do I know if clicked on the column Open1 or Open2 or Open3 etc ... I need to figure out which OpenN ( N = number ) he clicked on ... Thanks again, Sean. --- In flexcoders@yahoogroups.com, helihobby [EMAIL PROTECTED] wrote: Hello, Can anyone help out ... I know the Data Grid Cell's Row and Colum Index. How can I retrieve the data in that cell if I know these two values ? Thank you, Sean. Now that's room service! Choose from over 150,000 hotels in 45,000 destinations on Yahoo! Travel to find your fit. http://farechase.yahoo.com/promo-generic-14795097 No need to miss a message. Get email on-the-go with Yahoo! Mail for Mobile. Get started. http://mobile.yahoo.com/mail
Re: [flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column index
I think my last lines are a bit vague and confusing. It isnt the actual index in the dataprovider.. but rather the offset in the data provider of properties depending on how you have laid out your elements. So the reliability of this method depends - needless to say - your prior knowledge of how the properties are to be laid out in the datagrid. It's one of the setbacks for trying to find the item from the visual indeces p --- leds usop [EMAIL PROTECTED] wrote: OMG i just realized I just gave you the reverse of what you are asking for haha. my bad. anyway, try using datagrid's indicesToIndex() method. It will return the index (in your dataprovider)... I assume you can then look up your dataprovider to determine which item/prop/text is which? :) Cheers! -leds --- leds usop [EMAIL PROTECTED] wrote: Hi listen for the itemclickevent and then use specifically ListEvent as the event type paramter of the listener then use the rowIndex and columnindex properties like so: private function test(e:ListEvent):void{ trace(e.rowIndex.toString()); trace(e.columnIndex.toString()); } be aware however that these indeces are relative to the visual grid, hence the headers (if you use them) are counted. Just compensate approprately.. like subtract 1 from the rowindex. :) Cheers! -leds --- helihobby [EMAIL PROTECTED] wrote: Thank you all for the answers ... The problem is that I need to know which cell he clicked on. Or in other words, what is the text that displayed on that cell... Getting the complete ArrayCollection object which the user clicked on is easy as I can ( as u guys mentioned ) simply grab the event and do event.selectedItem.SOME_PROP_HERE However, I need to know which prop he clicked on as during runtime I do not know the name of SOME_PROP_HERE. In my case I have over 40 columns per row and each carries the name of Open1 Open2 Open3 Open4 . etc ... So of course doing event.selectedItem.Open1 will work. But how do I know if clicked on the column Open1 or Open2 or Open3 etc ... I need to figure out which OpenN ( N = number ) he clicked on ... Thanks again, Sean. --- In flexcoders@yahoogroups.com, helihobby [EMAIL PROTECTED] wrote: Hello, Can anyone help out ... I know the Data Grid Cell's Row and Colum Index. How can I retrieve the data in that cell if I know these two values ? Thank you, Sean. Now that's room service! Choose from over 150,000 hotels in 45,000 destinations on Yahoo! Travel to find your fit. http://farechase.yahoo.com/promo-generic-14795097 No need to miss a message. Get email on-the-go with Yahoo! Mail for Mobile. Get started. http://mobile.yahoo.com/mail Don't get soaked. Take a quick peak at the forecast with the Yahoo! Search weather shortcut. http://tools.search.yahoo.com/shortcuts/#loc_weather
[flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column index
Found the solution from a guy who emailed me ... thx This is what worked for me: yourDataGrid.addEventListener(ListEvent.ITEM_CLICK, setColumnCopy); function setColumnCopy(){ _selectedCol = yourDataGrid.columns[event.columnIndex].dataField; Alert.show(yourDataGrid.selectedItem[_selectedCol]); } As always, Thank you for all the help and support. BRA HREF=http://www.helihobby.com/html/alon_desingpattern.html;FONT SIZE=-1 FACE=Verdana,Tahoma,Arial,Helvetica,Sans-serifRead my solution for Flex Component communication here.../FONT/A BRSean - A HREF=http://www.helihobby.com;FONT SIZE=-1 FACE=Verdana,Tahoma,Arial,Helvetica,Sans-serifHeliHobby.com/FONT
[flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column index
As always, Thank you for all the help and support. Regards, Sean - http://www.HeliHobby.com P.S. You can read my solution for Flex Component communication here: http://www.helihobby.com/html/alon_desingpattern.html --- In flexcoders@yahoogroups.com, helihobby [EMAIL PROTECTED] wrote: Found the solution from a guy who emailed me ... thx This is what worked for me: yourDataGrid.addEventListener(ListEvent.ITEM_CLICK, setColumnCopy); function setColumnCopy(){ _selectedCol = yourDataGrid.columns[event.columnIndex].dataField; Alert.show(yourDataGrid.selectedItem[_selectedCol]); } As always, Thank you for all the help and support. BRA HREF=http://www.helihobby.com/html/alon_desingpattern.html;FONT SIZE=-1 FACE=Verdana,Tahoma,Arial,Helvetica,Sans-serifRead my solution for Flex Component communication here.../FONT/A BRSean - A HREF=http://www.helihobby.com;FONT SIZE=-1 FACE=Verdana,Tahoma,Arial,Helvetica,Sans- serifHeliHobby.com/FONT
[flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column index
Is it possible ? Sean. --- In flexcoders@yahoogroups.com, helihobby [EMAIL PROTECTED] wrote: Hello, Can anyone help out ... I know the Data Grid Cell's Row and Colum Index. How can I retrieve the data in that cell if I know these two values ? Thank you, Sean.
[flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column index
Hi Sean Have a look in help for 'datagrid event': ?xml version=1.0? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; mx:Script ![CDATA[ import mx.events.ListEvent; private function itemClickEvent(event:ListEvent):void { clickColumn.text=String(event.columnIndex); clickRow.text=String(event.rowIndex); eventType.text=event.type; } ]] /mx:Script mx:DataGrid id=myGrid width=350 height=150 itemClick=itemClickEvent(event); mx:ArrayCollection mx:Object Artist=Pavement Price=11.99 Album=Slanted and Enchanted / mx:Object Artist=Pavement Album=Brighten the Corners Price=11.99 / /mx:ArrayCollection /mx:DataGrid mx:TextArea id=clickColumn / mx:TextArea id=clickRow / mx:TextArea id=eventType / /mx:Application To access the selected item in the event handler, you can use the currentTarget property of the event object, and the selectedItem property of the DataGrid control, as the following code shows: var selectedArtist:String=event.currentTarget.selectedItem.Artist; Cheers Wayne --- In flexcoders@yahoogroups.com, helihobby [EMAIL PROTECTED] wrote: Is it possible ? Sean. --- In flexcoders@yahoogroups.com, helihobby helihobby@ wrote: Hello, Can anyone help out ... I know the Data Grid Cell's Row and Colum Index. How can I retrieve the data in that cell if I know these two values ? Thank you, Sean.
[flexcoders] Re: Can anyone help on getting data from a grid cell .. I know the row/column in
Hmmm... answered this last night from gmail, but it didn't post... Look at the n-th element of your datagrid's dataProvider (equal to the row index value), with the property name equal to the column's dataField name... paying attention to the verticalScrollPosition of your datagrid to offset what's visible... Brendan --- In flexcoders@yahoogroups.com, helihobby [EMAIL PROTECTED] wrote: Hello, Can anyone help out ... I know the Data Grid Cell's Row and Colum Index. How can I retrieve the data in that cell if I know these two values ? Thank you, Sean.