Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1450
Expand/Collapse All Childs
posted

Hello

Our customers which use our application, which is using the xamPivotGrid control had a interesting request. When they expand a row or column, and they holding a modifier like "Control", they want to expand also all children of the clicked (header)cell.

Then following nodes should also expand:

Is this possible?

I implented the Expand/Collapse All accordingly to your sample i found for it. And also i worked with the event 'AxisExpansionChanging' to catch the clicked cell and check if there is a pressed modifier. But i'm not able to figure out, how to combine these two approaches. Can you help me with that?

We use the FlatDataSource right now, and it should work with that.

The Expand/Collapse All is realised with a Background-Worker where the code asyncronously works with the IFilterViewModel and expands/collapses all members.

  • 34430
    Offline posted

    Hello Christian,

    Unfortunately, I am unable to see most of the screenshots that you have attached, but I believe I understand the requirement that you are looking for. As I understand it, you are looking to be able to have your users click an expandable hierarchy in the XamPivotGrid and while holding "CTRL" that particular record will fully expand. Please let me know if this is incorrect, as the following is based upon that.

    There doesn't currently exist a method built-in to the XamPivotGrid that can expand a specific header fully that I am aware of, but this can be done from the AxisExpansionChanging event as you had mentioned. In order to do this, I would recommend recursively looping through the XamPivotGrid.GridLayout.Row/ColumnHeaderCells collection, which will contain a full list of the currently visible PivotHeaderCells. If you place this recursion in a Dispatcher.BeginInvoke inside of the AxisExpansionChanging event, it should contain the header cells that are the children of the cell that fired that event.

    From there, you can loop through the contents of the Row or Column HeaderCells collection and check the ParentCell.Member against the PivotHeaderCell.Member. This will designate that there exists a child PivotHeaderCell with the parent cell that has been CTRL + Clicked, and you can mark that header cell's IsExpanded property as true.

    I have attached a sample project to demonstrate how the above can be achieved recursively. One issue here that I've found is that with larger hierarchies, sometimes the Dispatcher.BeginInvoke isn't quite enough to have the child header cells be loaded, and so the sample project uses a DispatcherTimer. This timer is started in the AxisExpansionChanging event and makes a call to the custom-created expansion method every so often. Currently in the sample project, this is fired every second, but it is possible that this could be reduced.

    I hope this helps. Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

    XamPivotGridExpansionModifierCase.zip