PDA

View Full Version : Datagrid problem - completely confused!


handycam
08-05-2007, 02:33 PM
I built a simple app to load xml with e4x into a datagrid. It works. Now I need to get the selected items in the grid.

However, the TRACE statement keeps coming up blank:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="getData.send()">
<mx:Script>
<![CDATA[
import mx.rpc.events.*;
[Bindable]
private var myData:XMLList;
private var myResults:Array;
private function checkData(event:ResultEvent):void {
myData = event.result.stock;
}
private function getList(event:MouseEvent):void {
myResults = dg1.selectedItems;
}
]]>
</mx:Script>
<mx:Panel>
<mx:VBox>
<mx:DataGrid dataProvider="{myData}" id="dg1">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="name"/>
<mx:DataGridColumn headerText="Column 2" dataField="author"/>
</mx:columns>
</mx:DataGrid>
<mx:Button id="btn" label="ClickME" click="getList(event)"/>
</mx:VBox>
</mx:Panel>
<mx:HTTPService id="getData" url="books.xml" resultFormat="e4x" result="checkData(event)"/>
</mx:Application>


I can't for the life of me figure out why. Can anyone pleae help?

Here's the XML is used, from a FOE book:


<?xml version="1.0" encoding="iso-8859-1"?>
<books>
<stock>
<name>The Picasso Code</name>
<author>Dan Blue</author>
<category>Fiction</category>
<description>Cubist paintings reveal a secret society of people who really look like that</description>
</stock>
<stock>
<name>Here With the Wind</name>
<author>Margaret Middle</author>
<category>Fiction</category>
<description>In this edition, nobody in the south really gives a damn</description>
</stock>
<stock>
<name>Harry Potluck and the Chamber of Money</name>
<author>J.K. Roughly</author>
<category>Fiction</category>
<description>Young wizard finds the real pot-of-gold and retires</description>
</stock>
</books>