header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Vipin
Points:0
Posts:0

7/6/2010 10:26:45 AM

Title: get Corresponding column value Datagrid


I have a datagrid with some columns and a button placed inside the datagrid on each row.
My problem is I want to get any correponding column value by clicking on its corresponding button.Pls help.



1
Friend
Points: 690
Posts:0
7/6/2010 10:43:16 AM



on click of button you an get the index value of the row of DataGrid. Know use that index value to get data of any column at that position from the dataProvider. i.e


mydataProvider[index].name

2
Flash_Guy
Points: 830
Posts:0
7/6/2010 10:52:16 AM



check this example


<?xml version="1.0" ?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
	<mx:Script>
		<![CDATA[
			import mx.collections.XMLListCollection;
			import mx.controls.DataGrid;
			
			private var xml:XML =	<root>
				  <item>one</item>
				  <item>two</item>
				  <item>three</item>
				</root>;
			
			[Bindable] private var myDataProvider:XMLListCollection = new
				XMLListCollection(xml..item);
			public function changeText(event:MouseEvent):void{     
				//traced the item in row of button clicked
trace(myDataProvider.getItemAt(myDataGrid.selectedIndex));
				
			}
		]]>
	</mx:Script>
	<mx:DataGrid id="myDataGrid" dataProvider="{myDataProvider}">
		<mx:columns>
			<mx:DataGridColumn headerText="String Text"
							   dataField="item">
				<mx:itemRenderer>
					<mx:Component>
						<mx:Text text="{data}"/>
					</mx:Component>
				</mx:itemRenderer>
			</mx:DataGridColumn>
			<mx:DataGridColumn headerText="CheckBox">
				<mx:itemRenderer>
					<mx:Component>
						<mx:Button label="Get Item"
									   click="outerDocument.changeText(event)"/>
					</mx:Component>
				</mx:itemRenderer>
			</mx:DataGridColumn>
		</mx:columns>
	</mx:DataGrid> 
</mx:Application>




Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 0+6 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions