You could create a “global”
variable (instance member) to act as the dataProvider for the totals DataGrid.
It would be an array of objects, with properties for each column.
Loop over the dataProvider, do the
calculations, and update the variable in the result handler, or on cellEdit if
the dg is editable.
Tracy
From: flexcoders@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf
Of [EMAIL PROTECTED]
Sent: Tuesday, September 13, 2005
1:05 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re:
Datagrid columns resize
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 id="mygrid2" height="22"
width="100%" resizableColumns="false"
sortableColumns="false">
<mx:columns>
<mx:Array>
<mx:DataGridColumn headerText="totals"
textAlign="right" />
<mx:DataGridColumn headerText="age" textAlign="right"
/>
<mx:DataGridColumn headerText="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>
</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
------------------------ Yahoo! Groups Sponsor
--------------------~-->
Most low income households are not online. Help
bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/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/
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS