For Clarity: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" backgroundColor="#FFFFFF"> <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:Model id="TestSource" source="test.xml"/> <mx:DataGrid dataProvider="{TestSource.testinfo}" rowCount="4" width="100%" id="myGrid" alternatingRowColors="[#CCCCCC,#FFFFFF]" columnStretch="setWidth(event);" marginBottom="0"> <mx:columns> <mx:Array> <mx:DataGridColumn headerText="Names" columnName="names" /> <mx:DataGridColumn headerText="Ages" columnName="age" textAlign="right" /> <mx:DataGridColumn headerText="Weights" columnName="weight" textAlign="right"/> </mx:Array> </mx:columns> </mx:DataGrid> <mx:DataGrid dataProvider="{TestSource.testinfo}" rowHeight="30" width="100%" borderThickness="0" vGridLineColor="#FFFFFF" hGridLineColor="#FFFFFF" id="myGrid2" columnStretch="setWidth (event);" headerHeight="0" rowCount="1" > <mx:columns> <mx:Array> <mx:DataGridColumn /> <mx:DataGridColumn fontWeight="bold" textAlign="right" columnName="text" /> <mx:DataGridColumn fontWeight="bold" textAlign="right" columnName="weights"/> </mx:Array> </mx:columns> </mx:DataGrid> </mx:Application>
And the XML: <?xml version="1.0" encoding="UTF-8"?> <test> <testinfo> <names>name 1</names> <age>32</age> <weight>200</weight> <text>Total Weight</text> <weights>780</weights> </testinfo> <testinfo> <names>name 2</names> <age>40</age> <weight>100</weight> <text/> <weights/> </testinfo> <testinfo> <names>name 3</names> <age>23</age> <weight>150</weight> <text/> <weights/> </testinfo> <testinfo> <names>name 2</names> <age>55</age> <weight>330</weight> <text/> <weights/> </testinfo> </test> --- In flexcoders@yahoogroups.com, "digital_eyezed" <[EMAIL PROTECTED]> wrote: > Hi, > > I tend to do this by adding another element to the dataprovider > which has the totals, then you use the same dataprovider for the > second dataGrid but use the columnName of the totals to display them. > > I have modified your code below to show this. > > --- In flexcoders@yahoogroups.com, [EMAIL PROTECTED] wrote: > > I have a data grid with three columns. NAME AGE and WEIGHT. I > want to be > > able to get the total of the age and weight columns and place them > in the > > bottom row which you showed me how to do > > previously. Thanks. > > > > <?xml version="1.0"?> > > <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"> > > > > <mx:Script> > > <![CDATA[ > > public function setWidth(event){ > > if(event.target == _level0.mygrid){ > > mygrid2.getColumnAt(event.columnIndex).width = > > mygrid.getColumnAt(event.columnIndex).width ; > > } > > } > > ]]> > > </mx:Script> > > > > <mx:VBox verticalGap="-1" width="400"> > > > > <mx:DataGrid id="mygrid" width="100%" columnStretch="setWidth > (event);" > > > > > <mx:Model id="TestSource" source="test.xml"/> > > > > <mx:dataProvider>{TestSource.testinfo}</mx:dataProvider> > > <mx:columns> > > <mx:Array> > > <mx:DataGridColumn headerText="name" columnName="names" /> > > <mx:DataGridColumn headerText="age" columnName="age" > > textAlign="right" /> > > <mx:DataGridColumn headerText="weight" columnName="weight" > > textAlign="right"/> > > </mx:Array> > > </mx:columns> > > </mx:DataGrid> > > > <mx:DataGrid rowHeight="30" width="100%" borderThickness="0" > vGridLineColor="#FFFFFF" hGridLineColor="#FFFFFF" id="myGrid2" > columnStretch="setWidth(event);" headerHeight="0" rowCount="1"> > > <mx:dataProvider>{TestSource.totals}</mx:dataProvider> > > <mx:columns> > > <mx:Array> > > <mx:DataGridColumn/> > > <mx:DataGridColumn columnName="text" textAlign="right" /> > > <mx:DataGridColumn columnName="weight"textAlign="right" /> > > </mx:Array> > > </mx:columns> > > </mx:DataGrid> > > > > </mx:VBox> > > > > </mx:Application> > > > > <test> > > <testinfo> > > <names>name 1</names> > > <age>32</age> > > <weight>200</weight> > > </testinfo> > > <testinfo> > > <names>name 2</names> > > <age>40</age> > > <weight>100</weight> > > </testinfo> > > <testinfo> > > <names>name 3</names> > > <age>23</age> > > <weight>150</weight> > > </testinfo> > > <testinfo> > > <names>name 2</names> > > <age>55</age> > > <weight>330</weight> > > </testinfo> > > <totals> > > <text>Total Weight:</text> > > <weight>780</weight> > > </totals> > > </test> > > > > > > > > CONFIDENTIALITY STATEMENT - This message and any files or text > attached to > > it are intended only for the recipients named above, and contain > > information that may be confidential or privileged. If you are > not an > > intended recipient, you must not read, copy, use, or disclose this > > communication. Please also notify the sender by replying to this > message, > > and then delete all copies of it from your system. Thank you. > > > > > > > > "digital_eyezed" <[EMAIL PROTECTED]> > > Sent by: flexcoders@yahoogroups.com > > 09/13/2005 12:50 AM > > Please respond to > > flexcoders@yahoogroups.com > > > > > > To > > flexcoders@yahoogroups.com > > cc > > > > Subject > > [flexcoders] Re: Datagrid columns resize > > > > > > > > > > > > > > Can you explain a bit more about what you need? > > > > Thanks > > > > Iain > > > > --- In flexcoders@yahoogroups.com, [EMAIL PROTECTED] wrote: > > > Thank you, that's perfect. Would you be able to tell me the > > correct syntax > > > to get compute the colums in the datagrid? thanks > > > > > > > > > > > > > > > CONFIDENTIALITY STATEMENT - This message and any files or text > > attached to > > > it are intended only for the recipients named above, and contain > > > information that may be confidential or privileged. If you are > > not an > > > intended recipient, you must not read, copy, use, or disclose > this > > > communication. Please also notify the sender by replying to > this > > message, > > > and then delete all copies of it from your system. Thank you. > > > > > > > > > > > > "digital_eyezed" <[EMAIL PROTECTED]> > > > Sent by: flexcoders@yahoogroups.com > > > 09/12/2005 03:26 PM > > > Please respond to > > > flexcoders@yahoogroups.com > > > > > > > > > To > > > flexcoders@yahoogroups.com > > > cc > > > > > > Subject > > > [flexcoders] Re: Datagrid columns resize > > > > > > > > > > > > > > > > > > > > > Sorry, remove the cellrenderer: > > > > > > <?xml version="1.0" encoding="utf-8"?> > > > <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" > > > backgroundColor="#FFFFFF"> > > > <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" > > > alternatingRowColors="[#CCCCCC,#FFFFFF]" columnStretch="setWidth > > > (event);" marginBottom="0"> > > > <mx:columns> > > > <mx:Array> > > > <mx:DataGridColumn headerText="Key" /> > > > <mx:DataGridColumn headerText="Value"/> > > > <mx:DataGridColumn headerText="Test"/> > > > <mx:DataGridColumn headerText="Test2"/> > > > </mx:Array> > > > </mx:columns> > > > </mx:DataGrid> > > > <mx:DataGrid rowHeight="30" width="100%" borderThickness="0" > > > vGridLineColor="#FFFFFF" hGridLineColor="#FFFFFF" id="myGrid2" > > > columnStretch="setWidth(event);" headerHeight="0" rowCount="1"> > > > <mx:columns> > > > <mx:Array> > > > <mx:DataGridColumn /> > > > <mx:DataGridColumn /> > > > <mx:DataGridColumn /> > > > <mx:DataGridColumn /> > > > </mx:Array> > > > </mx:columns> > > > </mx:DataGrid> > > > </mx:Application> > > > > > > --- In flexcoders@yahoogroups.com, "digital_eyezed" > > > <[EMAIL PROTECTED]> wrote: > > > > This does it: > > > > > > > > <?xml version="1.0" encoding="utf-8"?> > > > > <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" > > > > backgroundColor="#FFFFFF"> > > > > <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" > > > > alternatingRowColors="[#CCCCCC,#FFFFFF]" > columnStretch="setWidth > > > > (event);" marginBottom="0"> > > > > <mx:columns> > > > > <mx:Array> > > > > <mx:DataGridColumn headerText="Key" > > > > cellRenderer="MyTotal"/> > > > > <mx:DataGridColumn headerText="Value"/> > > > > <mx:DataGridColumn headerText="Test"/> > > > > <mx:DataGridColumn headerText="Test2"/> > > > > </mx:Array> > > > > </mx:columns> > > > > </mx:DataGrid> > > > > <mx:DataGrid rowHeight="30" width="100%" borderThickness="0" > > > > vGridLineColor="#FFFFFF" hGridLineColor="#FFFFFF" id="myGrid2" > > > > columnStretch="setWidth(event);" headerHeight="0" rowCount="1"> > > > > <mx:columns> > > > > <mx:Array> > > > > <mx:DataGridColumn /> > > > > <mx:DataGridColumn /> > > > > <mx:DataGridColumn cellRenderer="MyTotal"/> > > > > <mx:DataGridColumn /> > > > > </mx:Array> > > > > </mx:columns> > > > > </mx:DataGrid> > > > > </mx:Application> > > > > > > > > --- In flexcoders@yahoogroups.com, "Joe" <[EMAIL PROTECTED]> > > wrote: > > > > > I have a datagrid on top of another datagrid. The bottom > grid > > is > > > > for > > > > > totals of the top grid. When I resize the a column in the > top > > > grid > > > > I > > > > > want the bottom grid to adopt the new column width. Is this > > > > possible to > > > > > do? I know I can call a function using columnStretch. So I > > guess > > > I > > > > > would need to know the correct actionscript syntax. Thanks > > > > > > > > > > > > > > > > > > > > > -- > > > 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 > > > > > > > > > > > > -- > > 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 ------------------------ Yahoo! Groups Sponsor --------------------~--> Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life. http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/nhFolB/TM --------------------------------------------------------------------~-> -- 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/