Recently, we addressed an issue for a customer:

Issue : One thing I have found is that (in some cases) if I set the dataprovider for the datagrid after the datagrid is initially created, the widths are correctly set, but if I set the dataprovider in the mxml code for the grid and bind an array collection to it, the column width settings are not respected.    


Another issue we have is that when we change the dataprovider content for the grid, the columns resize themselves after refreshing the dataprovider.  An example project showing this is attached.  In this project, the dataprovider contains a single record and is loaded when the datagrid loads.  When hitting the 'Refresh Data Provider' button at the bottom of the app, I clear the dataprovider, refresh the dataprovider, add the record back to the dataprovider, and then refresh the dataprovider again.  As you can see, the column widths spontaneously resize themselves after the refresh.  Can you please advise as to how we can better control our column widths under these conditions.


The problem here is that there are two rounds of code that run to calculate the widths of columns. The first round is the default SDK code - we need it to run to figure out the initial set of column widths. The second pass is our code, which basically adds support for things that are covered using our columnWidthMode. Column Width Modes are an very nuanced topic, as you can observe from this documentation : But irrespective of that - the issue is that once they are calculated, the input for the next round of calculations is not the same as before. So what we have done, is added a property - autoApplyColumnWidths - this will cause the column widths to calculate only once, and that too when you call it. This way, we dont override the initially calculated column widths. 


<grids:ExtendedAdvancedDataGrid  id="dgCfgList" 




And then you manually call applyColumnWidths after you set the data provider - make sure you call validateNow prior to this, so the first pass of the width calculation executes.