Full code with logic:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>
<mx:Script>
<![CDATA[
        public function setWidth(event){
                if (event.target == _level0.myGrid2){
                myGrid.getColumnAt(event.columnIndex).width = 
myGrid2.getColumnAt(event.columnIndex).width ;
                }
                else if(event.target == _level0.myGrid){
                myGrid2.getColumnAt(event.columnIndex).width = 
myGrid.getColumnAt(event.columnIndex).width ;
                }
        }
]]>
</mx:Script>
<mx:DataGrid width="100%" id="myGrid" columnStretch="setWidth
(event);">
        <mx:columns>
                <mx:Array>
                        <mx:DataGridColumn columnName="key" 
headerText="Key"/>
                        <mx:DataGridColumn columnName="value" 
headerText="Value"/>
                        <mx:DataGridColumn columnName="test" 
headerText="Test"/>
                        <mx:DataGridColumn columnName="test2" 
headerText="Test2"/>
                </mx:Array>
        </mx:columns>
</mx:DataGrid>
<mx:DataGrid width="100%" id="myGrid2" columnStretch="setWidth
(event);">
        <mx:columns>
                <mx:Array>
                        <mx:DataGridColumn columnName="key" 
headerText="Key"/>
                        <mx:DataGridColumn columnName="value" 
headerText="Value"/>
                        <mx:DataGridColumn columnName="test" 
headerText="Test"/>
                        <mx:DataGridColumn columnName="test2" 
headerText="Test2"/>
                </mx:Array>
        </mx:columns>
</mx:DataGrid>
</mx:Application>

--- In [email protected], "digital_eyezed" 
<[EMAIL PROTECTED]> wrote:
> Ok I did it:
> 
> create a columnStretch event handler which uses this function:
> 
>       public function setWidth(event){
>               myGrid.getColumnAt(event.columnIndex).width = 
> myGrid2.getColumnAt(event.columnIndex).width ;
>       }
> 
> Needs some logic to make it work both ways but it's nearly there.
> 
> Iain
> 
> --- In [email protected], "digital_eyezed" 
> <[EMAIL PROTECTED]> wrote:
> > Hi,
> > 
> > How do I make the column of one datarid equal in width to that 
of 
> a 
> > different datagrid?
> > 
> > So if a user stretches a column on one datagrid, the same column 
> on 
> > the second datagrid also resizes to the same width dynamically.
> > 
> > Thanks in advance.
> > 
> > Iain




------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12h7lirk3/M=362131.6882499.7825260.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1122855253/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life 
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to