Skip the Array entirely.

 

Use the "devicesCollection" directly as the dataProvider:

nvrsInPoolList.dataProvider = devicesCollection;



Then do:

<mx:List id="nvrsInPoolList"
labelField="[EMAIL PROTECTED]" .../>

 

labelField tells List what to display.

 

Then nvrsInPoolList.selectedItem will contain the entire xml node and
you can access any value from it,

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of anuj sharma
Sent: Monday, December 01, 2008 4:27 PM
To: [email protected]
Subject: Re: [flexcoders] Is there any Name -Value Pair concept for
Arrays?

 

Hi Tracy 
Yes I have attached code to tell you exactly how I am doing this. I am
assigning an Array to my dataProvider and my array consists of XML
Nodes. I hope I answer all of your questions. I am putting array of XML
Nodes as dataProviders in List. I hope the code below will help you.
Please let me know how to solve the problem of displaying different
entities as labels and values in the List.
Thanks for all your help
Anuj

//MXML Code
<mx:HTTPService id="devicesXML" method="GET" resultFormat="e4x"
        result="devicesXMLHandler(event)" showBusyCursor="true">        
    </mx:HTTPService>    

<mx:List id="nvrsInPoolList" allowMultipleSelection="true"
dragMoveEnabled="true" dragEnabled="true" dropEnabled="true" 
        y="105" x="17" height="462" width="294"/>

//Action Script Code

[Bindable]            
private var devicesInList:Array=new Array();
[Bindable]
private var devicesList:XMLList;
[Bindable]
private var poolsList:XMLList;
[Bindable]
private var devicesCollection:XMLListCollection; 
            

public function init()
{
devicesXML.url="http://121.0.30.6:8182/config/devices
<http://121.0.30.6:8182/config/devices> ";    
                    devicesXML.useProxy=false;    
}
private function devicesXMLHandler(event:ResultEvent):void
            {
                devicesList = event.result.device;
                devicesCollection = new XMLListCollection(devicesList);

               //Checks every device
                for each (var devicesInPool:* in devicesList) {
                    var deviceName:String = [EMAIL PROTECTED];
                    var label:[EMAIL PROTECTED];
                   
                    devicesInList.push(deviceName);    
}
    nvrsInPoolList.dataProvider = devicesInList;
}
                

On Mon, Dec 1, 2008 at 1:24 PM, Tracy Spratt <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:

dataProviders do not "display" anything.  But whatever your display
component, there is a way to specify which property on the item you want
to display.

 

You say your dataProvider is an "array".  Are you sure?  How are you
sure?  Are you using the work "array" in its purely technical sense, or
in a more generic sense, that includes "associative array" and
"arrayCollection"?

 

If it is an Array, what is it an array of? (dynamic objects, scalar
values, xml nodes?)

 

What is your resultFormat?

 

Have you inspected your data in the result handler function?

 

Tracy

 

________________________________

From: [email protected] <mailto:[email protected]>
[mailto:[email protected] <mailto:[email protected]> ]
On Behalf Of anuj181
Sent: Monday, December 01, 2008 2:48 PM
To: [email protected] <mailto:[email protected]> 
Subject: [flexcoders] Is there any Name -Value Pair concept for Arrays?

 

Hi All
I am retrieving some data using HTTP from PostGres database. I would
be successfully able to put all the entries in UDN's in the list box
(using REST Calls). Now my requirement is that I need to display an
attribute name Friendly name which is already in the database as the
label (VISUAL entry ) in the list but when user performs different
operations like drag and drop, I need the complete string in form XML
to be send. So to make long story short I need to display friendly
name as list entries but behind the curtain that label have exact
complete value coming from the Database. Now is there any way that I
can tell my data provider (which is an Array in my case) that to
display just the specific attribute for the database and while doing
operation send the whole value.
Any links, examples and help will be appreciated.
Thanks
Anuj

 

 

Reply via email to