Search code examples
flex4dataprovider

Data not refreshing when using actionscript to assign dataprovider


My problem is when I assign the dataprovider for a spark list using actionscript it does not automatically update the list. example:

I have a list: < s:List id="fiterList" allowMultipleSelection="true" width="100%" height="100%"/>

and I use actionscript to assign the dataprovider: filterList.dataProvider = model.ADEPTList; (where model.ADEPTList is an ArrayCollection)

When I use an event to update model.ADEPTList the data does not show up in the list.

HOWEVER,

if I instead declare the dataprovider in the MXML like this: < s:List id="filterList" allowMultipleSelection="true" width="100%" height="100%" dataProvider="{model.ADEPTList}"/>

When the event updates model.ADEPTList it DOES show up in the list. Why is this and how can I get the list to update when assigning the dataprovider using actionscript? Thanks


Solution

  • That's because that's only an assignment, you're not binding your list's dataProvider to model.ADEPTList.

    You have to read more about flex binding mechanisms. In AS3 you could use:

    BindingUtils.bindProperty(filterList,"dataProvider",model,"ADEPTList");