0

I have a flat data array that comes form a remoteobject, I want to group whatever is to be grouped, but leave single items (the ones with no common data with anything else) alone and without grouping, it's annoying to open each node only to find there's just one item inside, so there was no need to put it inside that group anyway.

Is this something anyone has done? I can't find any reference and I don't know if getting the hierarchicaldata out of the groupingcollection and then iterate thru it would be any good, sounds like a lot of duplicate work.

Gustavo Parrado
  • 126
  • 1
  • 8
  • From what I've seen this isn't possible furthermore making it happen isn't trivial, sorry to be the bearer of bad news. I dug into the GroupingCollection.as code some and found that the refresh() method calls a private method called makeGroupedCollection() which in turn calls another private method buildGroups(), in that method there's a loop where the work is done. As I see it your options are A extend GroupingCollection and override refresh, or "monkey patch" a copy of GroupingCollection and modify the loop (even so ADG or other UI may be touchy about how it expects GC to present data) GL – shaunhusain Jan 28 '11 at 21:55
  • Alternatively, you could make a renderer that displays the count of the grouped collection so at least you know that certain nodes only have 1 child (we've used this and it makes good sense to me, maintains consistent behavior of grouped rows yet don't need to expand to see that there is only 1, although I understand this isn't the same as just seeing the data inline). – shaunhusain Jan 28 '11 at 21:56

2 Answers2

0

I ended up doing what shaunhusain said, I created my own copy of groupingcollection and monkeypatched the way it creates the groups, not clean enough for posting or general use yet, but working on it.

Gustavo Parrado
  • 126
  • 1
  • 8
0

can also be accomplished by using a groupitemrenderer and hiding the disclosure icon based on the number of children.

<mx:AdvancedDataGrid id="adg" 
     groupItemRenderer="my.namespace.GroupedItemRenderer"
</mx:AdvancedDataGrid>

GroupedItemRenderer is a subclass of AdvancedDataGridGroupItemRenderer

In updateDisplayList :

if (data && data.hasOwnProperty("children")) {
disclosureIcon.visible = (data.children.length > 0);
}
StephenNYC
  • 1,234
  • 3
  • 12
  • 29