开发者

How can I hide a list component when it contains no items?

开发者 https://www.devze.com 2022-12-28 06:23 出处:网络
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

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 coul开发者_如何学Pythond do this when setting the dataProvider, but it seems like there should be an event or something else that I could be using.


You could try

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

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消