Auto Collapse Groups on Drop

Developer
Jan 3, 2011 at 6:09 PM

I am using this control to display 1000s of items.  When a customer drags and drops a column header to the group container I'd like the items to auto collapse showing all available groups.  When a second level of grouping is added, I'd like to auto expand the parent group and simulateously colapse the new group.  How can I accomplish this functionality?

Coordinator
Feb 15, 2011 at 7:55 AM

Hi,

There is no out of the box support for this so you are going to have to do a little coding. If I were you I would create a new Sections.ListSection.GroupState based property in the Column class called say ‘DefaultGroupState’. Then in the ListSection  class there is a method called GetSectionState, this gets called by the layout routine when it needs to know if a group is expanded or not – you need to plug in your new DefaultGroupState state into the logic. The variable _groupExpansionState contains all the explicitly set user collapse/expand states, so I would check to see if the user has overridden your default by checking in groupExpansionState then if not set the state to being what’s in the Column object.

Finally there is an event on ListControl.Columns.GroupedItems.DataChanged where you can receive events fired when a column has been added or removed from the grouping set. This is where I would set the defaults for the columns depending on what the state of the groupings are. You could also clear out the user defaults in _groupExpansionState as well (you might need to make a clear method public for this).

 

Hope this helps...

Regards

Lee