Inline data provider for DataGrid
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:DataGrid id="myDG" width="350"> <mx:dataProvider> <mx:ArrayCollection> <mx:source> <mx:Object Artist="A" Album="aa" Price="11.99" /> <mx:Object Artist="B" Album="bb" Price="11.99" /> </mx:source> </mx:ArrayCollection> </mx:dataProvider> <mx:columns> <mx:DataGridColumn dataField="Artist" /> <mx:DataGridColumn dataField="Album" /> <mx:DataGridColumn id="price" dataField="Price" visible="false" /> </mx:columns> </mx:DataGrid> <mx:Button label="Toggle Column" click="price.visible = !price.visible;" /> </mx:Application>