views:

55

answers:

3

I have a List of items which is based on the contents of the "category" that a user selects

When the user changes selection, I change the dataProvider of the list be be the contents of the current category.

Sometimes the list contains items, sometimes it does not

Is there a way of hiding the list when it has no items?

I know that I could do this when setting the dataProvider, but it seems like there should be an event or something else that I could be using.

+2  A: 

You could try

visible="{myList.dataProvider.length>0}"
includeInLayout="{myList.dataProvider.length>0}"

where "myList" is the id of your List component.

Robusto
A: 

My first solution to this was to override set dataProvider:

override public function set dataProvider(value:IList):void {
    super.dataProvider = value;
    this.setVisible(value.length > 0);
}

This did work, however Robusto's solution works also and is preferable IMO.

shinyhappydan
A: 

Thank you Robusto!

Grateful Dude