Thanks for the code! However, I get errors when I try to
execute the code and I have more columns than are visible on the
screen in the Datagrid. Here is the error:
Optimized width of col 14 to 165
TypeError: Error #1010: A term is undefined and has no
properties.
at mx.controls::DataGrid/
http://www.adobe.com/2006/flex/mx/internal::resizeColumn()[C:\dev\GMC\ sdk\frameworks\mx\controls\DataGrid.as:2379
at mx.controls.dataGridClasses::DataGridColumn/set
width()[C:\dev\GMC\sdk\frameworks\mx\controls\dataGridClasses\DataGri dColumn.as:1048]
at
view.forms::securitysetup/optimizeColumnWidths()[C:\Documents and
Settings\Misc\Desktop\MPR\MPRPro\view\forms\securitysetup.mxml:417]
at view.forms::securitysetup/dataHandler()[C:\Documents and
Settings\Misc\Desktop\MPR\MPRPro\view\forms\securitysetup.mxml:116]
at
view.forms::securitysetup/___Operation1_result()[C:\Documents and
Settings\Misc\Desktop\MPR\MPRPro\view\forms\securitysetup.mxml:432]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.rpc::AbstractOperation/
http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\dev\ enterprise_gmc\frameworks\mx\rpc\AbstractOperation.as:179
at mx.rpc::AbstractInvoker/
http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\dev\ent erprise_gmc\frameworks\mx\rpc\AbstractInvoker.as:167
at
mx.rpc::Responder/result()[C:\dev\enterprise_gmc\frameworks\mx\rpc\Re sponder.as:48]
at
mx.rpc::AsyncRequest/acknowledge()[C:\dev\enterprise_gmc\frameworks\m x\rpc\AsyncRequest.as:82]
at
DirectHTTPMessageResponder/completeHandler()[C:\dev\enterprise_gmc\fr ameworks\mx\messaging\channels\DirectHTTPChannel.as:359]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
It shoots me to the code in the DataGrid.as in the
ResizeColumns function and I think the error occurs because the
code is trying to resize a column that is not visible in the
datagrid (i.e. you have to horizontally scroll to find it).
Here is where it stops in DataGrid.as: if (w <
visibleColumns[col].minWidth)
Please help me troubleshoot this because the code is awesome
and I really need it to work.
Thanks