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.
gourav
Points:540
Posts:0

11/18/2010 10:38:38 PM

Title: how to get IitemRenderer component index


Hi Friend ,

i have some problem in itemRenderer plz help me.

i have one list with IR like this in my project.





<s:List id="leftList" itemRendererFunction="myItemRendererFunction" dataProvider="{filterUpcomingWordAC}"  borderAlpha="0"  contentBackgroundAlpha="0" 
						color="#f4f4f4" borderVisible="false" labelField="target"
						allowMultipleSelection="false"		
						dragStart="mytest(event)"
				itemRenderer="gourav.cairngorm.view.innerView.itemrenderer.LeftListIR"
						>					
				</s:List>





Regarding this list i have one itemRenderer given blow :





<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:fx="http://ns.adobe.com/mxml/2009" 
		 xmlns:s="library://ns.adobe.com/flex/spark"  creationComplete="init()"         dragStart="vbox1_dragStartHandler(event)"
		 xmlns:mx="library://ns.adobe.com/flex/mx"
		 styleName="listIR"
		 > 

	<mx:Button id="btnleftList" mouseDown="doDrag(event)" fontFamily="Calibri"  label="{data.target}" 
			    styleName="columnlblLeft"
			   fontWeight="bold" buttonMode="true" width="114.75" height="24.05"  /> 
	<mx:Spacer height="10" />	  

	
</mx:VBox>


Now i have Output like 10 Buttons in one List. My problem: i want to visible true and false any button in list, for that i want itemRenderer index . plz reply me the solution if need any help ask me thanks in advance



1
Flash_Guy
Points: 850
Posts:0
11/19/2010 4:59:49 AM



you can get the clicked index number inside click handler of the list component.

2
gourav
Points: 540
Posts:0
11/21/2010 10:34:26 PM



i cant find any property clicked index number did u mean "event.clickCount" property.

can u explain what is idea?


Thanks 4 reply

3
Syron Mack
Points: 0
Posts:0
11/22/2010 10:13:36 PM



check this example , in this example you can get the index of item clicked which is same as item renderer index. In this example we are deleting the row clicked




<?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{     
				trace(myDataProvider.getItemAt(myDataGrid.selectedIndex));
				//myDataProvider.setItemAt("Changed Text",myDataGrid.selectedIndex)
				myDataProvider.removeItemAt(myDataGrid.selectedIndex)
				myDataProvider.refresh();
			}
		]]>
	</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="Change"
									   click="outerDocument.changeText(event)"/>
					</mx:Component>
				</mx:itemRenderer>
			</mx:DataGridColumn>
		</mx:columns>
	</mx:DataGrid> 
</mx:Application>


4
gourav
Points: 540
Posts:0
11/22/2010 11:07:12 PM



Hi, thanks for reply.

yes this is fine with inline itemRenderer but my reqrement is something else, plz see the example that i write at the top of the page.



Problem:
suppose we have a :List and in this list we a Vbox->Button in custome itemRenderer,suppose there is 10 Vbox->Button is shown to user now i want to know index of any button so that i can visible true or false of that button for any event.


Thanks

5
NileshPawar
Points: 280
Posts:0
12/3/2010 2:39:24 AM






private function removeClickedItemRendererIndexFromList():void{
				var parentList:List = owner as List; // Parent List of your Itemrenderer
 				parentList.dataProvider.removeItemAt(parentList.dataProvider.getItemIndex(data)); // Get current item renderer index from Parent List
	 			parentList.parentDocument.invalidateDisplayList();
	 		}

Regards, Nilesh


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 2+3 



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