When setting an arrayCollection as a dataProvider to a comboBox programmatically,if the arrayCollection has just one element,i need to do a small validation:
> public resultHandler(event:ResultEvent):void{
arrColl = event.result.FlexData.ListData as ArrayCollection;
//to check if the arrColl has only one element
if(arrColl == null)
myComboBox.dataProvider = event.result.FlexData.ListData
else
myComboBox.dataProvider = arrColl;
}
I would like to know,if there is a way to skip this validation every time.Is there a way to set dataProvider such that i dont have to check if the collection has one or more elements?
event.result.FlexData.ListData
. The only thing that's different is whether you're binding to an ArrayCollection or whatever object is returned inevent.result.FlexData.ListData
. I'm not seeing where you check to see if there's only one element or not. Is there a reason you don't just return anArrayCollection
of one item if only one item is returned? It would keep you from having to do this check. – Jason Towne