Posted by: Sameer on: November 4, 2009
There were some concerns over the performance of GroupingCollection class while grouping and calculating summaries.
So, a new class GroupingCollection2 is introduced in the data visualization components.
The major improvements in GroupingCollection2 are -
1. Grouping performance improved.
2. Summary calculation performance improved. Now, instead of looping over the data again and again, summaries are calculated in a single loop.
3. When using async refresh, the summaries are calculated as soon as each Group is built. Earlier, the summaries were calculated only after all the Groups have been made.
What has changed -
1. Introduced class GroupingCollection2 which replaces existing class GroupingCollection.
2. Introduced class SummaryField2 which replaces existing class SummaryField.
No no, classes GroupingCollection and SummaryField are not removed.
They will continue to exist to maintain backward compatibility.
So, you can use either GroupingCollection or GroupingCollection2 and AdvancedDataGrid will continue to work
The difference between SummaryField and SummaryField2 is -
SummaryField2 does not have “operation” and “summaryFunction” properties.
A new property “summaryOperation” in added in SummaryField2. It is an Object which takes one of the following -
* SUM, MIN, MAX, AVG or COUNT as String.
OR
* An implemtatation of mx.collections.ISummaryCalculator for calculating custom summaries.
The default value is SUM.
API changes -
1. Method refresh() has been changed in GroupingCollection2. The syntax now is –
function refresh(async:Boolean = false, dispatchCollectionEvents:Boolean = false):Boolean;
Code changes required to start using GroupingCollection2 -
1. Use GroupingCollection2 instead of GroupingCollection.
2. Use SummaryField2 instead of SummaryField.
3. Replace operation/summaryFunction in SummaryField with summaryOperation in SummaryField2.
An example is shown here:
With GroupingCollection –
<mx:GroupingCollection id="gc" source="{arr}">
<mx:Grouping>
<mx:GroupingField name="name" >
<mx:SummaryRow>
<mx:SummaryField dataField="sal"
operation="MAX" />
</mx:SummaryRow>
</mx:GroupingField>
</mx:Grouping>
</mx:GroupingCollection>
With GroupingCollection2 –
<mx:GroupingCollection2 id="gc" source="{arr}">
<mx:Grouping>
<mx:GroupingField name="name">
<mx:SummaryRow >
<mx:SummaryField2 dataField="sal"
summaryOperation="MAX" />
</mx:SummaryRow>
</mx:GroupingField>
</mx:Grouping>
</mx:GroupingCollection2>
Try it and let us know your feedback.
This remains a Flex 4 only class right? Any chance this iwll get officially backported to Flex 3? I’m using Sreenivas’s GC2 without issues but it would be nice if it was ‘offical’ http://flexpearls.blogspot.com/2008/06/groupingcollection-with-some-better.html
So this GroupLabel I’m aware of, but its interesting how with GC (1) I saw node labels and with GC2 I didn’t. I only had the expand/collapse arrows. And my group is pretty simple as I dont use Summary Rows.
All I used to have is:
groupField1.name = “someDataField”; // this is the label in my provider
Do I need to specify columnName in ADGColumn for this to work?
Hi Sameer,
I have a page with two tabs (using view stacks) and advanced datagrid as display component. Both have same grouping fields(say A->-B->C heirarchy). And both have ‘SingleRow’ selection mode. I can move from ADG1 to ADG2 thru context menu.
My issue here is that,if I am right clicking one cell in ADG1 and going to ADG2 I want to move to same cell in the ADG2. This is posssible if I am keeping the selection mode
‘SingleCell’ for ADG2 and finding the row and column index of the selected cell and then setting the same in ADG2.
But I want to keep the selection mode as ‘SingleRow’for getting the selected row from the grid(for showing the graph for selected row) and also for opening the nodes when clicking on any cell(other than grouping field A /B/C). Otherwise this feature will fail.
Could you please help me to solve thse issues?
Also, is there any way to solve the latter issue(if we are going to set ’singleCell’ and try to solve the first issue)?
Expecting your suggestions..
Hi Sameer,
Thanks for your quick response!!!
I have GroupingFields (A,B and C hierarchy) and 12 columns(Jan-Dec) in both ADG.So if I clicking on a cell corresponding to row C and column Jan and moving to ADG2, then same cell should be selected in ADG2(corresponding to C-Jan). As you said we cannot select single
cell if selection mode is’SingleRow’, I have to keep the selection mode as ‘SingleCell’ in ADG2. Now , I am able to point the corresponding cell in ADG2.
But, I think we will not get the grouping field values when clicking on a cell if selection mode is singleCell.
My requirement is that if I am selecting one cell(underany column) in the ADG2, I need to get the correspoding values of the grouping fields A, B and C. and 12 columns. i.e entire selecteItem of the AdvancedGrid. (for showing graphical view of the selected row)
I have tried the following code
itemClick=”adg_itemClick(event);)
private function adg_itemClick(event:ListEvent):void{
AdvancedDataGrid(event.currentTarget).selectionMode = “singleRow”;
var adgSelectedItem:Object = AdvancedDataGrid(event.currentTarget).
selectedItem;
var selectedA:String = adgSelectedItem["A"];
var selectedB:String = adgSelectedItem["B"];
var selectedA:StringselectedC = adgSelectedItem["C"];
Alert.show(“row A”+selectedA );
Alert.show(“row B”+selectedB);
Alert.show(“row C”+selectedC);
AdvancedDataGrid(event.currentTarget).selectedCells = new Array();
}
I haven’t test it completely. But facing some problems in clearing the initially selected cell (while landing to ADG2 from ADG1).
Thanks
Hey Sameer,
I’m using Advance datagrid and using combo selection to group columns. For example, If I select “Status” from drop down my grid is group by Status. So my grouping code is something like below which runs on combo selection.
var mygroup:GroupingCollection=new GroupingCollection();
mygroup.source = dominoXML.lastResult.opcenter;
var group:Grouping = new Grouping();
group.fields = [new GroupingField(groupField)];
mygroup.grouping = group;
mygroup.refresh();
Set the dataProvider to the new grouping collection
viewGrid.dataProvider = mygroup
Now I would to display total number of records from each category like below if I assume “Status” is selected in combo .
Status
———————————
Active(2)
bla bla
bla bla
Close(1)
bla bla
Can you please point me to right direction ?
Rishi
hi sameer,
Its working perfectly..
thanks a lot!!!
Hi Sameer,
Can we adjust th vertical scroll bar position to center of the ADG when expanding a row ? Currently , if we are expanding the bottom rows, we need scroll down to see the opened nodes. It would be better if opened nodes automaticaly positioned at center /beginning of the grid view.
Please give your thoughts.
Thanks
Hey Sameer,
I’m having problem in sorting my date column in Advance data grid with “DD-MMM-YYYY” format . It doesn’t give proper sort.
I’m using following code in DateTipFunction of Advance data grid ,
private function formatDate(itemA:Object, itemB:Object):int {
//return dateFormatter.format(item.dob);
return ObjectUtil.dateCompare(DateField.stringToDate(itemA.dob, “DD/MMM/YYYY”), DateField.stringToDate(itemB.dob, “DD/MMM/YYYY”));
}
What’s wrong. I must use European format ( DD-MMM-YYYY ) .
Rishi
November 5, 2009 at 1:59 am
Where can we find the release. Couldn’t find anything in Adobe SVN.
Thanks
November 5, 2009 at 11:57 am
You can download Flash Builder 4 beta 2 release from http://labs.adobe.com/technologies/flashbuilder4/. This beta release contains the data visualization components with GroupingCollection2.