Thursday, June 14, 2007

AdvancedDataGrid Summary roll up sample

Here is a sample application showing Summary roll up feature in AdvancedDataGrid and GroupingCollection. The GroupingCollection takes flat data in the form of a ICollectionView object as input and generates a grouped collection based on the GroupingField information provided. The example shows grouping on the Region and Territory data fields. Of-course don't forget to call the refresh method on the GroupingCollection to make the collection to generate the grouping. If Summary is desired Summaries with SummaryRow and SummaryField information can be added to each GroupingField object. The SummaryRow has a summaryPlacement property which can take multiple values as input from the possible values of group, first and last. I have used group to show the roll up of summary values. SummaryField has a operation property which by default supports "SUM", "MIN", "MAX", "AVG" and "COUNT". ADGColumn has support for a formatter which can be used to format cell values using any Flex formatter. I have used currency formatter to place a $ symbol. ADG and ADGColumn have a style function property which can be used to set style values on a particular cell based on its data content. The example uses this to change the font color to red. Oh! ADG has loads of features. Check it out. Before I forget here is MXML file for the sample.

9 comments:

Nate said...

Awesome. I saw your link on Flex Coders. I actually figured out how do it but I still had some questions. Your code should be very usefull.

adir1 said...

I have summaries randomly appear/disappear on our ADG. Same app, I run it once, no summaries, run it again, summaries.

Debugged everything, it's all good... ever encountered such issues?

Sreenivas said...

This is the first time I am hearing this. If you have a sample code which you can sure reproducing this issue you can send it to me or log a bug. So that the DMV team can fix this.

DEVSACHIN said...
This comment has been removed by the author.
DEVSACHIN said...

Hi ,
Is there any event by which we can detect that Vscroll bar is being activated in ADG?
My requirment is to add few event listener to VScroll bar at runtime.

Thanks
Sachin Dev Tripathi

Unknown said...

I am getting the following error when I try running the mxml ... "Property getRootModel not found on mx.collections.HierarchicalCollectionView and there is no default value." This is for adg.dataProvider.getRootModel().canHaveChildren(data) present in formatSummary() function. How can I resolve this?

Sreenivas said...

Try using

adg.dataProvider.source.canHaveChildren(data)

Alfredo said...

That sure worked!

Very nice code, I was looking for this exact thing.

Thanks!

trailmarky said...

whoa!!!, you had a passion in blogging, thumbs up for your work of love.. Hehe very inspiring ideas,


anyway I'm william
mind if I put a link back to you?


(clickable) ------> Suit