Oops spoke too soon. I'm getting a TypeError: Error #1009: Cannot access a property or method of a null object reference when I click on the datagrid to send the ID. The code hasn't changed since the example below, but I'm not sure how to troubleshoot this one.
public function onSelectFirstGrid(event:Event):void { orgProgramRequest.addEventListener(Event.COMPLETE, onResult) //var params:Object = new Object(); //params['id'] = dgOrg.selectedItem.orgID; orgProgramRequest.send(dgOrg.selectedItem.orgID); } public function onResult(e:ResultEvent):void { var xmlResult:XML = e.result as XML; trace(xmlResult.toXMLString()); //is that the xml you expected? var xlResult:XMLList = xmlResult.children(); //or other expression trace(xlResult.length()); //is that the right expression? dg2data = new XMLListCollection(xlResult) trace(dg2data.getItemAt(0).toXMLString()); } [Bindable] public var dg2data: XMLListCollection; --- In flexcoders@yahoogroups.com, "its_llpj" <[EMAIL PROTECTED]> wrote: > > That's it! > > Thanks Tracy! Thanks everyone! > > > --- In flexcoders@yahoogroups.com, "Tracy Spratt" <tspratt@> wrote: > > > > Ah, yes of course, it almost certainly is. > > > > > > > > I suggest, in verbose style: > > > > var xmlResult:XML = e.result as XML; > > > > trace(xmlResult.toXMLString()); //is that the xml you expected? > > > > var xlResult:XMLList = xmlResult.children(); //or other expression > > > > trace(xlResult.length()); //is that the right expression? > > > > dg2data = new XMLListCollection(xlResult) > > > > trace(dg2data.getItemAt(0).toXMLString()); //to make It easy to know > > the dataField > > > > > > > > Tracy > > > > > > > > ________________________________ > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > > Behalf Of Alex Harui > > Sent: Thursday, September 06, 2007 2:03 PM > > To: flexcoders@yahoogroups.com > > Subject: RE: [flexcoders] Populating XMLListCollection and sending it to > > a Datagrid > > > > > > > > e.result may be XML and not XMLListCollection. > > > > > > > > ________________________________ > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > > Behalf Of Tracy Spratt > > Sent: Thursday, September 06, 2007 10:28 AM > > To: flexcoders@yahoogroups.com > > Subject: RE: [flexcoders] Populating XMLListCollection and sending it to > > a Datagrid > > > > Are you sure onResult is getting called? If so, trace out > > dg2data.toXMLString() to make sure you have what you expect. You should > > see readable xml. > > > > Make sure "name" is a first generation child node name in the item > > node. > > > > Tracy > > > > ________________________________ > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > > Behalf Of its_llpj > > Sent: Thursday, September 06, 2007 12:13 PM > > To: flexcoders@yahoogroups.com > > Subject: [flexcoders] Populating XMLListCollection and sending it to a > > Datagrid > > > > Hello, I'm trying to populate a datagrid. Here is my code. Everything > > works, but when I use the dataProvider dg2data within my datagrid it > > comes back empty. I know there is data there, but not sure if I'm > > missing something. > > > > public function onSelectFirstGrid(event:Event):void > > > > { > > myRequest.addEventListener(Event.COMPLETE, onResult) > > myRequest.send(dg.selectedItem.myID); > > } > > > > private function onResult(e:ResultEvent):void > > > > { > > dg2data = e.result as XMLListCollection; > > } > > > > private function onFault(e:FaultEvent):void > > > > { > > Alert.show(e.fault.message, "Could not load"); > > } > > > > [Bindable] > > public var dg2data: XMLListCollection; > > > > My DataGrid > > <mx:DataGrid id="dg2" width="100%" height="100%" rowCount="10" > > dataProvider="{dg2data}"> > > <mx:columns> > > <mx:DataGridColumn dataField="name" headerText="Name" /> > > </mx:columns> > > </mx:DataGrid> > > > > Thanks! > > >