Say if you need to populate a dropdownlist programatically and do not have access to a bindable object or array. You have to first of all create an ArrayCollection, then create an object. Add that object within the ArrayCollection then set the dataprovider of the combobox to point to that. Its incredible how something so simple can be so hard to achieve in Flex.
try {
var qnsArrayList:ArrayCollection = new ArrayCollection();
var counter:int;
for (counter = 0; counter < qnsArray.length; counter++) {
var obj:Object = {data:qnsArray[counter][0],label:qnsArray[counter][1]};
qnsArrayList.addItem(obj);
}
ddl_response.labelField = "label";
ddl_response.dataProvider = qnsArrayList;
} catch (error:Error) {
Alert.show(error.message);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment