Usually people like to write the AdvancedDataGrid component in mxml. But there are some scenarios where there is a need to create the grid dynamically.
Here is a simple sample in which an AdvancedDataGrid is created dynamically with column groups.
Source is posted here.