It's hard to say if you're on the right track or not because I still don't really understand what you're trying to do, or what it's not doing right now.
I'm going to take a stab in the dark and assume you are trying to get some kind of XML data from your class, then have your data grid update the display with the new information.
To update a display object every time the data changes, you will need to create a bindable var of type XMLListCollection, or ArrayCollection. Luckly, I am board, so I wrote a brief example of how to update a display object from data in a class w/ proper (in my opinion at least) OOP practices.
--==DataGridExample.mxml==--
Code:
<?xml version="1.0"?>
<!-- DataGrid control example. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.XMLListCollection;
import pkg.DataSelecter;
[Bindable]
private var myDataProvider:XMLListCollection;
private var myDataSelector:DataSelecter = new DataSelecter();
]]>
</mx:Script>
<mx:Panel title="DataGrid Control Example" height="100%" width="100%"
paddingTop="10" paddingLeft="10" paddingRight="10">
<mx:DataGrid id="dg" width="100%" height="100%" rowCount="5" dataProvider="{myDataProvider}">
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="Name"/>
<mx:DataGridColumn dataField="phone" headerText="Phone"/>
<mx:DataGridColumn dataField="email" headerText="Email"/>
</mx:columns>
</mx:DataGrid>
<mx:Button label="Get Data" click="myDataProvider = myDataSelector.getData();" />
</mx:Panel>
</mx:Application>
--==pkg/DataSelecter.as==--
Code:
package pkg
{
import mx.collections.XMLListCollection;
public class DataSelecter
{
private var myData:XML =
<data>
<employee>
<name>Christina Coenraets</name>
<phone>555-219-2270</phone>
<email>[email protected]</email>
<active>true</active>
</employee>
<employee>
<name>Joanne Wall</name>
<phone>555-219-2012</phone>
<email>[email protected]</email>
<active>true</active>
</employee>
<employee>
<name>Maurice Smith</name>
<phone>555-219-2012</phone>
<email>[email protected]</email>
<active>false</active>
</employee>
<employee>
<name>Mary Jones</name>
<phone>555-219-2000</phone>
<email>[email protected]</email>
<active>true</active>
</employee>
</data>;
public function getData():XMLListCollection {
return new XMLListCollection(myData.elements());
}
}
}
When you click the button, it will get the data from the class and update the DataGrid with it.
hope this helps,
...aaron