Search code examples
datagridflex4

Clear DataGrid in Flex including headers


I have an MX Datagrid which is populated with data as such:

<mx:DataGrid id="myDG_2" dataProvider={myDP} x="278" y="233">
        <mx:columns>
            <mx:DataGridColumn dataField="@id" headerText="ID"/>
            <mx:DataGridColumn dataField="@field" headerText="Field"/>
        </mx:columns>
    </mx:DataGrid>

Now I have a button, which when I click clear the datagrid, so I did:

myDG.dataProvider = "";

This clear the data but the headers remain, I need to clear the datagrid completely inclusive of the headers as well.

How to do this?

Thanks


Solution

  • Have you tried grid.columns=[]