views:

67

answers:

1

Hello everybody.

I'm new to Flex, but I've been exploring it with Flex Builder, and its pretty good.

Indeed the best for fast building of Web based Apps...

I'm trying to do something with eventListeners, but i still do a lot of messy code, so wanted help of those who already know flex.


I'm have a DataGrid, and its itens are added by another component, no problems with that.

I have buttons to Add, Remove and Edit the items inside the DataGrid. No problem with that too.

But i want those button to be enabled when the DataGrid as at least one item, and when it doesn't as any, all three buttons should be disabled.

How should i do it?

EDIT: Forgot to say: I think eventListeners are the best way. But.. you tell me.

+1  A: 

This should do it:

<mx:DataGrid id="mydg "dataProvider="{books}" horizontalGridLines="false"> </mx:DataGrid>

<mx:Button enabled={mydg.dataProvider.length!=0} label="my button"/>

Cheers,

Caspar.

CaspNZ
Just Perfect. CPU low height too. Thanks.
Fábio Antunes
(just noticed I'd left a few unneeded items in the datagrid code - remove the horizontalGridlines="false", and you can define the dataProvider as anything, not just "{books} ;-)
CaspNZ
I realized that, i never did added them. Thanks. :)
Fábio Antunes