exclude single items from grouping in groupingcollection

716 views Asked by At

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.

2

There are 2 answers

0
Gustavo Parrado On BEST ANSWER

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.

1
StephenNYC On

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);
}