Alex has provided a nice example for adding a DataGrid footer to your
component which might include the total value of a certain column:

http://blogs.adobe.com/aharui/item_renderers/

 

It's the April 17, 2007 entry.

 

Joan

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of simonjpalmer
Sent: Monday, February 04, 2008 2:01 AM
To: [email protected]
Subject: [flexcoders] Re: Datagrid Counting row and total value

 

I haven't seen a really simple way and it is not natively supported by
the datagrid component. You may want to check out the advanced data
grid, which I haven't used and I'm sure others can comment on. 

I ended up writing a custom component which has two data grids, one
containing the data and another which has one row which contains the
totals of the selected rows. It was a reasonable amount of work to
get it going, especially as this method of implementation comes with
problems like the column widths having to be managed on the total grid. 

Other issues which I had and you may or may not want to consider are:
- is your total a straightforward sum of the values? I was adding up
percentages in one column, so I needed some different rules for
summation, e.g. Average.
- do you have ratios and therefore the post-aggregation division
problem? Often the total for a ratio is sum(A)/sum(B) rather than
sum(A/B). Sometimes A or B are not columns in the grid. This gives
some complexity to calculating the totals.
- is there any formatting involved in any of your values, e.g.
currencies?
- if there are multiple currencies in the table how do you sum their
values?

It did take me a couple of days to get the component working as I
wanted, but I now use it everywhere and it is a very valuable feature. 

I thought about asking Adobe for help, but the reality is that there
is enough which is specific to my application that I would be very
surprised if a generic solution was desirable. 

If enough people ask I will publish my TotalGrid.
Simon

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Harry Saputra" <[EMAIL PROTECTED]> wrote:
>
> Yups, thanks, I have use arrayname.length, and its working.
> 
> And my second problem, how to get a total value in a label from one
field ?
> I have seen some example, but's its need to build some function and
etc. I
> try to search a simple way.
> 
> Thanks
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of shrikant.patil
> Sent: Monday, February 04, 2008 11:54 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: Re: [flexcoders] Datagrid Counting row and total value
> 
> 
> hi
> i thik u r using some kind of data provider like array or what
ever.......
> u can calculate the total number of records from that data provider
> structure, say for example the data provider may b the array, then u
can get
> total number of rows by using ;
> 
> arrayname.length property...
>

 

Reply via email to