PDA

View Full Version : amfphp loading combo box


llebron
03-13-2005, 05:14 PM
I am trying to use amfphp to load a combo box. I want to use to fields that are returned by the remoting call to create the combobox. I tried the rearrange fields formatter with ({label=Opportunity_Name; data=OpportunityID}) as the format options but I get an "undefined" for the select box entries.

I also tried creating an array form the results of the remoting call. However, I was never able to actually get any info into the array.

The only thing that works is doing a databinding between the remoting connector and the combobox adding the following line of actionscript:

mycombobox.labelField="Opportunity_Name";

Using the code I get a functioning select box, but I'm not sure that it would submit the correct data (OpportunityID).

I have searched through the forums but I haven't found a similar problem. Any help would be appreciated.

Luis

shawn_t
03-17-2005, 04:15 AM
I use dataglue to easily fill combo boxes with results from AMFPHP. This is an example when I'm trying to fill the combo box: languages_cb with the results from an AMFPHP call to getLanguages():

First declare your reply object:

var getLanguagesReply = new Object();

Then request your data using AMFPHP:

yourService.getLanguages(getLanguagesReply);

Finally, use dataglue to bind the results to your combo box:


getLanguagesReply.binder = function(record)
{
var dataObj = new Object();

dataObj.label = record.languageLabel;
dataObj.data = record;

return dataObj;
}

getLanguagesReply.onResult = function(result)
{
trace("server responded: Languages: " + result.getLength());
DataGlue.bindFormatFunction(language_cb, result, this.binder);
}


NOTE that I opt to set the data field to the original record so I always have access to all fields of the record when the combo box changes.

llebron
03-17-2005, 02:05 PM
Thanks for the info. I ended up solving the problem with the following code:


function getItems_Result(result) {
length = result['items'].length;
for($i=0; $i < length; $i++)
{
getItems_cb.addItem({label:result['items'][$i]['Opportunity_Name'], data:result['items'][$i]['OpportunityID']});
}
}

getItems = manageleads.getItems();



Luis