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

5/10/2010 8:13:36 PM

Title: Refresh datagrid



we want to refresh the datagrid at runtime(after insertion or deletion)
either automatically or by clicking button..



1
Brad
Points: 750
Posts:0
5/11/2010 1:10:24 AM



to refresh the dataGrid in flex you can refresh the dataProvider of the dataGrid on the button click event function

yourDataGridDataProvider.refresh();

2
Dinesh
Points: 0
Posts:0
5/11/2010 6:53:55 AM



Ya we have tried that, but its not working..
Can we some sample code..

3
Brad
Points: 750
Posts:0
5/11/2010 9:33:31 AM



check this sample to delete the row and use refresh method


<?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{     
				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="Delete Button">
				<mx:itemRenderer>
					<mx:Component>
						<mx:Button label="Delete"
									   click="outerDocument.changeText(event)"/>
					</mx:Component>
				</mx:itemRenderer>
			</mx:DataGridColumn>
		</mx:columns>
	</mx:DataGrid> 
</mx:Application>



4
cfcode
Points: 0
Posts:0
8/10/2010 12:28:00 PM



I have a related question... let's say my dataGrid (id="childGrid") is located in my Main.mxml file, but the resultHandler that adds data to my database is found in a separate file, named Component.mxml. When I try to add "childGrid.refresh()", I get the error: "1120: Access of undefined property: childGrid". What is the best way to get the childGrid property recognized in my component file?


5
Rex
Points: 1280
Posts:0
8/10/2010 8:57:16 PM



@cfcode you can use your components in main mxml using the application identifier
Application.application.childGrid.refresh();


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 2+2 



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