What I am trying to do is hide an entire column if the content is all null.
<mx:DataGrid width="100%" dataProvider="{service}" id="dg1">
<mx:columns>
<mx:DataGridColumn headerText="Location Origin" dataField="originLocation" visible="{data.originLocationExists}" />
<mx:DataGridColumn headerText="Location Destination" dataField="destinationLocation" visible="{data.destinationLocationExists}" />
<mx:DataGridColumn headerText="Location Group Origin" dataField="originLocationGroup" visible="{data.originLocationGroupExists}" />
<mx:DataGridColumn headerText="Location Group Destination" dataField="destinationLocationGroup" visible="{data.destinationLocationGroupExists}"/>
</mx:columns>
</mx:DataGrid>
In the sample above, sometimes all the data in the “Location Origin” will be null, so under the visible property I put a value which is either true or false depending on the data. But even when all the data is null and the visible property equals false, it still stays visible.
What can I do to fix this? And I am running in Flex 3.2
To go along with J_A_X’s answer, you could also add an eventListener for the dataProvider’s
CollectionEvent.COLLECTION_CHANGEevent and then evaluate if you need to hide any columns or not.