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.
Indrajit
Points:10
Posts:0

2/24/2011 11:06:13 PM

Title: item renderer in Flex 4


How I will get reference of object which has been added via item renderer.

Suppose I have added a custom component [which include a check box ] in display list via item renderer.
Now i want get the current status of the check box inside the custom component, whether it is selected or not.How I will do that.



1
bob_senior
Points: 1320
Posts:0
2/25/2011 11:07:38 AM



I think this example will help you . Here we are making a textbox editable true or false depending upon the checkbox in datagrid


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()">
	<mx:Script>
		<![CDATA[
			import mx.collections.ArrayCollection;
			
			[Bindable] private var users:ArrayCollection = new ArrayCollection();
			
			private function init():void {
				users = new ArrayCollection(myData.person);
			}
			public var abc="cdf";
			public function changeText(event:MouseEvent):void{   
			
				if(event.target.selected == true){
					//checkbox selected then edit cilum 2 and row 
					myDataGrid.editable=true;
					myDataGrid.editedItemPosition = {columnIndex:1, rowIndex:myDataGrid.selectedIndex};
				}else{
					//clear editable field when checkbox not selected
					myDataGrid.editable=false;
				}
			}
		]]>
	</mx:Script>
	<mx:Model id="myData">
		<users>
			<person>
				<name>Data1</name>
				<address>Address1</address>
			</person>
			<person>
				<name>Data2</name>
				<address>Address2</address>
			</person>
			<person>
				<name>Data3</name>
				<address>Address3</address>
			</person>      
		</users>
	</mx:Model>
	<mx:DataGrid id="myDataGrid" dataProvider="{users}"  initialize="{Application.application.abc=myDataGrid;trace(Application.application.abc)}" rowCount="5" width="300" height="200" editable="true"  >
		<mx:columns>
			<mx:DataGridColumn headerText="Name" width="100" dataField="name" editable="false" editorDataField="text" />
			<mx:DataGridColumn headerText="Addresss" dataField="address" width="200" editable="true" />
			<mx:DataGridColumn headerText="CheckBox">
				<mx:itemRenderer>
					<mx:Component>
						<mx:CheckBox label="Change" 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 7+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