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..
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();
5/11/2010 6:53:55 AM
Ya we have tried that, but its not working..
Can we some sample code..
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>
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?
8/10/2010 8:57:16 PM
@cfcode you can use your components in main mxml using the application identifier
Application.application.childGrid.refresh();