Oops yeah I misread that conditional + loop code.

 

But you ARE mangling your xml.  The default resultFormat of HTTPService
is "object", which causes flex to convert your xml into a nested object
structure.  Such a structure is hard to debug and is less flexible than
xml.

 

I advise using resultFormat="xml".  Type projectArray as
XMLListCollection. Then in the result handler do:

var xmlResult:XML = XML(event.result);

trace(xmlResult.toXMLString());  //to verify your structure

projectArray = new XMLListCOllection(xmlResult.projects.project);

trace(projectArray.length);  //to verify your list

 

Now, the dg.selectedItem will hold a <project> node.

 

You could bind directly to the selectedItem, but for easier
troubleshooting, I would declare a var(XMLList) to hold the detail
dataProvider(s), and assign them in a change handler of the dg:

var xmlItem:XML = XML(event.target.selectedItem);

trace(xmlItem.toXMLString()); //to verify your item structure

_xlResources = xmlItem.resources.item

 

Bind the repeater to _xlResources.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Mark
Sent: Thursday, September 27, 2007 8:54 PM
To: [email protected]
Subject: [flexcoders] Re: I really need some help on how to display
details of a record -arrayCollection

 

Hi Tracy and thank for replying -

1) ss += "<br>" I'm adding a little space with a break at the end of 
the textbox because for some reason when you go to print it the last 
line item wouldn't show, and this took care of it.
2) pResources.htmlText = ss writes it all in after the loop finishes
3) I'm putting my data into an ArrayCollection, yes.

Main Page -
<mx:HTTPService id="myXML" url=" getProjectXML.asp" 
result="extractProjects(event)"/>

public function extractProjects(event:ResultEvent):void {
projectArray = event.result.projects.project;
}

Change event on DataGrid -
<mx:DataGrid id="myDG" dataProvider="{projectArray}" 
headerStyleName="myDataGridFont" width="100%" height="100%" 
click="printPButton.enabled = true" change="detailsHolder.getInfo
(myDG.selectedItem)" >

Details Page - (Both samples are on here, the actionScript and the 
Repeater)

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " verticalGap="0" 
borderStyle="none">
<mx:Script>
<![CDATA[
public function getInfo(obj:Object, evt:Event):void {
var sss:String="";
// resources\\
if(obj.resources != null) {
for(var j:int = 0; j < obj.resources.item.length; j++){
ss += "<li>" + obj.resources.item[j] + "</li>";
}
ss += "<br>";
pResources.htmlText = ss;
} else {
pResources.htmlText = "";
}

pName.text = obj.name;
pLead.text = obj.lead;
pStatus.text = obj.status;

sDate.text = myDate.format(obj.startDate);
eDate.text = myDate.format(obj.endDate);
custName.text = obj.customerName;
pIssues.text = obj.issues;
pObjective.text = obj.objectives;
pDeliverable.text = obj.delioverables;
pAudience.text = obj.audience;
//
]]>
</mx:Script>
}

<mx:Label text="Resources:" styleName="detailLabels"/>
<mx:Text id="pResources" styleName="detailText" width="100%"/>

<mx:Label text="Action Steps:" styleName="detailLabels"/>
<mx:Repeater id="myR" 
dataProvider="{parentDocument.myDG.selectedItem}" >
<mx:Repeater id="myR2" 
dataProvider="{myR.currentItem.actionSteps.item}">
<mx:Text id="pActionSteps" htmlText="{myR2.currentItem}" 
styleName="bulleted" width="100%" />
</mx:Repeater>
</mx:Repeater>

</VBox>

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt" <[EMAIL PROTECTED]> 
wrote:
>
> For starters, these two lines:
> 
> ss += "<br>";
> pResources.htmlText = ss;
> 
> are between the clauses in the if statement. Does that even 
compile?
> 
> 
> 
> Second, you shouldn't really need to loop. An e4x expression will 
return
> an XMLList that your data-driven components can consume nicely. 
Bind
> the repeater to the DG .selectedItem.item. Repeater normally does 
not
> error with an empty dataProvider. You have something else going 
on.
> 
> 
> 
> But also you say ArrayCollection. Do you mean XMLListCollection? 
Are
> you mangling your pretty xml somehow?
> 
> 
> 
> You are kinda all over the place. Choose a path and post more 
code.
> 
> 
> 
> Tracy
> 

 

Reply via email to