actionscript-3apache-flexflex4.5flex-spark

is there a dataProviderChange event for dropdownlist?


I have a case where the SelectedItem isn't called after the data provider changes for a dropdownlist. is there a way to detect if such a change occurred? Thanks


Solution

  • Just about every public property in the Flex Framework has a 'propertyChanged' event that is dispatched from the properties set method. They are used primarily for binding purposes, but not usually formally documented.

    The dataProvider set method of a DropDownList does indeed dispatch a dataProviderChanged event. The code is several layers up in the hierarchy, as part of SkinnableDataContainer or if the skin for your 'SkinnableDataContainer' has a dataGroup it is dispatched from the DataGroup.

    But, this event will probably will not be exposed via code hinting in MXML. You'll have to listen for it in ActionScript:

    myList.addEventListener('dataProviderChanged', onDataProviderChanged);
    

    Keep in mind this event will always be dispatched when the dataProvider changes, regardless of what happens to the selectedItem property.